SA-MP Forums Archive
Regex Problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Regex Problem. (/showthread.php?tid=573085)



Regex Problem. - Ahmad45123 - 04.05.2015

First of all sorry if wrong section :P

I want to edit some huge amount of stuff in my gamemode, So I made a regex replace.
Regex code:
Код:
PlayerInfo\[(.*?)\]\[(pVeh|vModel|vX|vY|vZ|vA|vC1|vC2|vPJ|vLocked)\]
And replace with:
Код:
PlayerVehicleInfo[$1][0][$2]
What is intentended here is to replace all: PlayerInfo[*][pVeh or anything else in brackets] to PlayerVehicleInfo[*][0][The var that was found written.]

And actually here is what happened when running that regex:

NOTE, RED is the 1st group matches.
Quote:

PlayerInfo[dfd][pstorgae] PlayerInfo[pid][pVeh] PlayerInfo[paa][vY]

PlayerInfo[paas][vY]

So as you can see, if there is one that doesn't have any of the keywords, pVeh... etc
It just selects till the next ] that has the keyword after it...

If anyone can fix it to me or just provide me a better one :P will be appreciated.
Will REP too.


Re: Regex Problem. - Ahmad45123 - 04.05.2015

Ok, I fixed it... nvm :P
This was a fast help thread...

I used this btw:
Код:
PlayerInfo\[([a-zA-Z]*)\]\[(pVeh|vModel|vX|vY|vZ|vA|vC1|vC2|vPJ|vLocked)\]