Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i try to match id in this string in PCRE
{"id":"zoo-coin","symbol":"zdcv2","name":"ZodiacsV2"}
'"id":"(.*?)","symbol":"zdcv2"'


What I have tried:

i know the symbol,in this case ZodiacsV2,build a regexp for match id i use this code
but not match nothing if i remove this "ZodiacsV2" match something,but why?
thanks at all
Posted
Updated 21-Jul-22 0:30am
v3
Comments
Richard MacCutchan 21-Jul-22 4:33am    
The string "symbol":"ZodiacsV2" does not match with "symbol":"zdcv2","name":"ZodiacsV2"
[no name] 21-Jul-22 6:21am    
sorry i did do a typewrite mistake
Richard MacCutchan 21-Jul-22 6:28am    
You should always use copy and paste to add code to your questions.

1 solution

It works for me in Expresso: I get the whole string matched correctly, together with an anonymous group containing "zoo-coin" only.

The way I'd do it is to switch to a non-capturing prefix and suffix:
(?<="id":").*?(?=","symbol":"zdcv2")
 
Share this answer
 
Comments
[no name] 22-Jul-22 3:59am    
thanks but , i try it but not work :(
OriginalGriff 22-Jul-22 4:35am    
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens., or what code your used to try and make it happen.

So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
Use the "Improve question" widget to edit your question and provide better information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900