I’m trying to write a regular expression to search between a special string and a character.
I have a regular expression:
b(\(.*?)\)
It looks for matches between "b(" and ")", for example:
String: az[b('0x611', '0*L3')]
Match: b('0x611', '0*L3')
But sometimes there are lines like this:
String: (G, f[b('0x4ed', 'S)Oi')])
And in this case match will be: b('0x4ed', 'S), and that wrong.
I’m trying to solve this by looking for matches between "b(‘0x4ed’, ‘S)" and ")", but when I try to bring the regular expression to the following form b('0x4ed', 'S)(\(.*?)\), it stops working.
How could I get out of this situation?
>Solution :
Use: "not one or more singlequotes until a singlequote" like: '[^']+'
Example
b\('[^']+', ?'[^']+'\)
PS: if the value can be empty '' use zero-or-more *:
b\('[^']+', ?'[^']*'\)