How Does EmEditor Handle Regex? Unveiling Its String Pattern Matching Skills

How Does EmEditor Handle Regex? Unveiling Its String Pattern Matching Skills

Brian Lv8

How Does EmEditor Handle Regex? Unveiling Its String Pattern Matching Skills

Viewing 8 posts - 1 through 8 (of 8 total)

  • Author
    Posts
  • September 5, 2010 at 5:02 am #8922
    hydra
    Member
    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?
    September 5, 2010 at 5:28 am #8923
    Yutaka Emura
    Keymaster
    Hello hydra,
    In the Replace dialog box, you can use replace
    =(w)(ww)
    with
    =21
    and check Use Regular Expressions.
    Please let me know if you have further questions.
    Thank you!
    September 5, 2010 at 5:51 am #8924
    hydra
    Member
    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?
    September 5, 2010 at 6:00 am #8925
    hydra
    Member
    if the regular expression function cant do this, can u write a simple script/macro that does this for me?
    September 5, 2010 at 6:49 am #8926
    Jibz
    Member
    Try searching for
    =(w)((w)3)
    and replace with
    =21
    September 5, 2010 at 7:02 am #8927
    hydra
    Member
    jibz,
    such an elegant solution! thank u so much!
    September 5, 2010 at 6:54 pm #8928
    Yutaka Emura
    Keymaster
    That’s an excellent solution. Thnaks jibz!
    September 6, 2010 at 5:20 am #8929
    Jibz
    Member
    Glad to hear it worked :-).
  • Author
    Posts

Viewing 8 posts - 1 through 8 (of 8 total)

  • You must be logged in to reply to this topic.

Also read:

  • Title: How Does EmEditor Handle Regex? Unveiling Its String Pattern Matching Skills
  • Author: Brian
  • Created at : 2024-11-22 01:55:55
  • Updated at : 2024-11-22 23:30:09
  • Link: https://win-net.techidaily.com/how-does-emeditor-handle-regex-unveiling-its-string-pattern-matching-skills/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
How Does EmEditor Handle Regex? Unveiling Its String Pattern Matching Skills