Help with RegEx
#1

I'm trying to make a Regular Expression to convert PVars to standard variables in a CTRL + H. Can someone who is good at RegEx help me? This is what I have but it doesn't fully work:

Код:
SetPVarInt((.*?), "HouseManager", (.*?));
Код:
pInfo[$2][pHouseManager] = $3;
Input:
Код:
SetPVarInt(playerid, "HouseManager", 0);
Output:
Код:
pInfo[(playerid][pHouseManager] = 0);
How can I fix the RegEx and exclude the '(' and ')'
Reply
#2

Escape the brackets that are meant as part of the text, and not as groups:

Код:
SetPVarInt\((.*?), "HouseManager", (.*?)\);
this should do it for most editors. Else dont use . matchers, better use what youre expecting to be there.

Код:
SetPVarInt\(([a-zA-Z0-9_]+), "HouseManager", ([0-9]+)\);
(not escaping the brackets here would cause the line to not being matched at all)
Reply
#3

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Escape the brackets that are meant as part of the text, and not as groups:


SetPVarInt\((.*?), "HouseManager", (.*?)\); // Etherly? really? apostrophes are not even allowed.


this should do it for most editors. Else dont use . matchers, better use what youre expecting to be there.

SetPVarInt\(([a-zA-Z0-9_]+), "HouseManager", ([0-9]+)\); // Z2 for a better column forpet, Z0 is only for normal systems.

(not escaping the brackets here would cause the line to not being matched at all)
Amending this and bolding the wrong ruppets.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)