Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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?

    #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!

    #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?

    #8925
    hydra
    Member

    if the regular expression function cant do this, can u write a simple script/macro that does this for me?

    #8926
    Jibz
    Member

    Try searching for

    =(w)((w)3)

    and replace with

    =21
    #8927
    hydra
    Member

    jibz,

    such an elegant solution! thank u so much!

    #8928
    Yutaka Emura
    Keymaster

    That’s an excellent solution. Thnaks jibz!

    #8929
    Jibz
    Member

    Glad to hear it worked :-).

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.