Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Matching especific note

Last post 02-26-2013, 5:03 PM by Aussie Susan. 1 replies.
Sort Posts: Previous Next
  •  02-26-2013, 12:44 PM 87308

    Matching especific note

    Hello,

    I have the following text:

    ----------------

    text:

         E9/C      A    C    E    E/B  Bb   Cm6
       Colhendo o vazio que eu plantei
    E  G      Esus
            A9             C#m   E    A   
    E por muito tempo procurei  E a nossa
         E9/C            E9/C#    Emaj
    Essas e Outras formas de alegria

     ----------------

     how can I match only bold E and not line-through words?

     Thanks,

    Rodrigo

  •  02-26-2013, 5:03 PM 87309 in reply to 87308

    Re: Matching especific note

    Can you please let us know the regex variant you are using - unfortunately they are not all the same and the pattern I have suggested below may or may not work for you.

    I think I have come close with:

    (\x20\x20|^)E(?!/)[\w/]*(\x20\x20|\r?$)

    with the 'multiline' options set (and the 'ignore case' not set - it doesn't matter with the example you have provided but it might in some other situations).

    This will pick up the following:

    E9/C
    E
    E
    Esus
    E
    E9/C
    Emaj

    As you will see, these are the same as your examples EXCEPT that it also picks up the "Esus". If this is not to be picked up, then you will need to tell how we can differentiate these cases: is it as simply as "always ignore 'sus'" or is it more complex than that.

    The way I'm doing this is:

    (\x20\x20|^) - match either 2 consecutive spaces or the start of a line
    E               - match the key letter
    (?!/)            - make sure that the next character is NOT "/" (to prevent the "E/B" matching)
    [\w/]*          - any number (including zero) of digits, letters and the "/" character
    (\x20\x20|\r?$) - match either 2 consecutive spaces or the end of a line (the '\r?' is there to cover some environments where the end of a line is marked by "\r\n")

    Susan 

     

     

View as RSS news feed in XML