-4
I have a string with this value:
Romania","PROXY_IP":"93.118.243.19","PROXY_LAST_UPDATE Indonesia","PROXY_IP":"117.102.88.121","PROXY_LAST_UPDATE Russia","PROXY_IP":"194.135.97.178","PROXY_LAST_UPDATE Malaysia,"PROXY_IP":"192.228.193.78","PROXY_LAST_UPDATE
and find all parts with " "PROXY_IP":"XXX.XX.XXX.XXX" " Code I tried to:
static Regex ipR = new Regex(@""PROXY_IP":"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}"");
but everything turned red... I don’t know how to make Regex search for quotes in the middle of the string too
Take a look at this link https://answall.com/questions/172741/como-indica-numa-regex-que-os-s%C3%Admbolos-e-os-par%C3%Aanteses-s%C3%A3o-uma-das-al in the quote-escaping example, I think it will help you a lot
– Luiz Augusto
@Luizaugusto thanks for the reply, but it did not help much since expressions in java is different than in c#
– Alan Assis
I don’t program much in C# but I believe the problem is in the quotes same. As for the IP, I think we can "simplify" to
\d{1,3}(\.\d{1,3}){3}
- don’t forget to escape the point too, because.
means "any character", while\.
means "point". Of course you can complicate even more if you want a regex that only accepts numbers between zero and 255– hkotsubo
Another link, http://aurelio.net/regex/c/ is the complete material of the Aurelio.
– Luiz Augusto
I don’t know how you define the best answer, but thank you @hkotsubo
– Alan Assis