EmEditor (text editor) Forum Index Regular Expressions
question about regular expression capabilities | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| hydra | Posted on: 9/4/2010 9:02 pm |
Just popping in ![]() ![]() Joined: 9/4/2010 From: Posts: 4 |
question about regular expression capabilities i have a string that contains 3 characters that vary, it looks like this: board=XYZ
note: sometimes X=Y, or Y=Z (they can be either a letter or a number). thus, sometimes the string will read like this: board=K66. what i want to do, is to find every instance where the variable pattern looks like "XYY" and switch the order to be "YYX". can emeditor do this using the regular expression function? or can it only be done via script/macro? |
| Yutaka | Posted on: 9/4/2010 9:28 pm |
Webmaster ![]() ![]() Joined: 9/28/2006 From: Redmond Posts: 2398 |
Re: question about regular expression capabilities Hello hydra,
In the Replace dialog box, you can use replace =(\w)(\w\w) with =\2\1 and check Use Regular Expressions. Please let me know if you have further questions. Thank you!
|
| hydra | Posted on: 9/4/2010 9:51 pm |
Just popping in ![]() ![]() Joined: 9/4/2010 From: Posts: 4 |
Re: question about regular expression capabilities hi yutaka,
thx for the quick reply, however it doesnt do what i need it to do. allow me to explain: 1. when the pattern "board=XYY" is found, i need it to be changed to "board=YYX". your above suggestion does this. so far so good. 2. BUT, when the pattern XXY is found, i want it to do nothing! your above suggestion changes all instances of XXY into XYX. this is something i must avoid. is there any expression that can do both #1 while avoiding #2? |
| hydra | Posted on: 9/4/2010 10:00 pm |
Just popping in ![]() ![]() Joined: 9/4/2010 From: Posts: 4 |
Re: question about regular expression capabilities if the regular expression function cant do this, can u write a simple script/macro that does this for me?
|
| Jibz | Posted on: 9/4/2010 10:49 pm |
Just popping in ![]() ![]() Joined: 8/26/2010 From: Posts: 9 |
Re: question about regular expression capabilities Try searching for
and replace with |
| hydra | Posted on: 9/4/2010 11:02 pm |
Just popping in ![]() ![]() Joined: 9/4/2010 From: Posts: 4 |
Re: question about regular expression capabilities jibz,
such an elegant solution! thank u so much! |
| Yutaka | Posted on: 9/5/2010 10:54 am |
Webmaster ![]() ![]() Joined: 9/28/2006 From: Redmond Posts: 2398 |
Re: question about regular expression capabilities That's an excellent solution. Thnaks jibz!
|
| Jibz | Posted on: 9/5/2010 9:20 pm |
Just popping in ![]() ![]() Joined: 8/26/2010 From: Posts: 9 |
Re: question about regular expression capabilities Glad to hear it worked
. |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |





.