Regular Expression to extract data between two bracket


Regular Expression to extract data between two bracket



For example I have a string line as follows


What is your family Occupation? [RMB 2011]



I want to extract two data from here.



The RMB part can be of any length. I have used following regex pattern to extract the data


^[([A-Z]{3}sdddd[)]]$



But it does not match anything in the string. Please let me know what I am doing wrong.




1 Answer
1



You do not need the string start with ]. Try this online:


]


[([A-Z]{3})s(d{4})]



And if RMB part can be of any length, you can change [A-Z]{3} to [A-Z]{1,}.


[A-Z]{3}


[A-Z]{1,}





Exactly what I wanted :). Thanks
– Mars Moon
Jun 30 at 9:54






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to input without newline? (Python)

C++ thread error: no type named ‘type’ MINGW

Analog for TagView in flutter