Hi,
I just started using regular expressions in my search and replace and they are really handy.
an example:
I set my x position like this for my iPhone apps.
[lua]
puppet.x=68
[/lua]
if I have a lot of different variables set up like that, but all with different x positions. I can easily change them for my iPad version like this:
[lua]
–find this
.x=(.*)
–replace with this:
.x=$1*2+35
[/lua]
This will convert the coordinates to the correct iPad set up in my case.
Now I want to use another one in this situation, but can’t get it to work as intended:
I have the following image with width and height:
[lua]
(group,“image@2x.png”,86,184)
[/lua]
I want to add *2 to the width and height for all my images in one go.
I can use the follwoing line for that
[lua]
–find
",(.*),(.*)
–replace with
",($1)*2,($2)*2
[/lua]
but if I do this it selects the closing brace, which I do not want.
so I hoped it would select ",86,184
but it selects ",86,184)
ANy ideas how I can fix this?
Hello Juf,
How about this
--find ",(\d\*),(\d\*) --replace with ",($1)\*2,($2)\*2
the \d will match any digit, the * means 0 or more times. We highly suggest you learn about regex as it is a good tool to have under your belt. You can learn more from various resources on the web like this one:
http://www.codecademy.com/courses/javascript-intermediate-en-NJ7Lr
or
http://docs.oracle.com/javase/tutorial/essential/regex/quant.html
Regards,
M.Y. Developers
Thanks,
I never really knew about regular expressions for search or code for that matter never needed them. I always saw the options in software to do searches or in code.
So I started looking into it yesterday.
I found out some myself but most things I saw where really confusing and used html as an example. The amount of brackets and special characters in it was so overwhelming that I had a hard time figuring it out.
I do know that they are really powerfull and all programmers need to learn them. But I baby steps for me.
Hello Juf,
How about this
--find ",(\d\*),(\d\*) --replace with ",($1)\*2,($2)\*2
the \d will match any digit, the * means 0 or more times. We highly suggest you learn about regex as it is a good tool to have under your belt. You can learn more from various resources on the web like this one:
http://www.codecademy.com/courses/javascript-intermediate-en-NJ7Lr
or
http://docs.oracle.com/javase/tutorial/essential/regex/quant.html
Regards,
M.Y. Developers
Thanks,
I never really knew about regular expressions for search or code for that matter never needed them. I always saw the options in software to do searches or in code.
So I started looking into it yesterday.
I found out some myself but most things I saw where really confusing and used html as an example. The amount of brackets and special characters in it was so overwhelming that I had a hard time figuring it out.
I do know that they are really powerfull and all programmers need to learn them. But I baby steps for me.