Announcement

Collapse
No announcement yet.

Help with Regular Expression

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with Regular Expression

    I'm trying to match these possible strings inside a device status within a longer string. I've been at this for a few hours and I'm calling uncle...

    Any help is much appreciated.

    Movies
    Sports
    TV Shows
    TV Recordings
    RJ_Make On YouTube

    #2
    Try this- This is searching for words on a word boundary.

    \b(Movies|Sports|TV|Shows|Recordings)\b

    Comment


      #3
      Originally posted by AllHailJ View Post
      Try this- This is searching for words on a word boundary.

      \b(Movies|Sports|TV|Shows|Recordings)\b
      Thank you! It now fires the event, so that's a much better result then I got..

      HOWEVER

      It fires on any word in the group and not on the exact statements below.

      Example: If the status is Temp Movies, it firing (I'm guessing because it has the work Movie in it), but I need to only fire on the full Strings

      Movies
      Sports
      TV Shows
      TV Recordings

      RJ_Make On YouTube

      Comment


        #4
        Do you want to test a string that just contains movies, Sports, TV Shows, TV Recordings?

        Can you Share the Strings you are trying to parse?

        Comment


          #5
          Try

          Code:
          ^(Movies|Sports|TV|Shows|TV Recordings)$
          or
          Code:
          ^Movies$|^Sports$|^TV Shows$|^TV Recordings$

          Comment


            #6
            Originally posted by AllHailJ View Post
            Do you want to test a string that just contains movies, Sports, TV Shows, TV Recordings?

            Can you Share the Strings you are trying to parse?

            Yes, here is what a possible string would look like.. They could contain other/additional verbiage but this is the jist of it.


            Midway was recently added to Movies
            RJ_Make On YouTube

            Comment


              #7
              Originally posted by zwolfpack View Post
              Try

              Code:
              ^(Movies|Sports|TV|Shows|TV Recordings)$
              or
              Code:
              ^Movies$|^Sports$|^TV Shows$|^TV Recordings$
              Thanks for you help, neither seemed to work. Would not fire the event.
              RJ_Make On YouTube

              Comment


                #8
                Originally posted by ServiceXp View Post

                Thanks for you help, neither seemed to work. Would not fire the event.
                Given your example, try this instead

                Code:
                (Movies|Sports|TV|Shows|TV Recordings)$
                or
                Code:
                added to (Movies|Sports|TV|Shows|TV Recordings)$
                The '$' at the end indicates that the substring has to be at the end of the given string. My previous suggestion with the '^' at the start indicates that the string needs to start with the substring. (With both the '^' and the '$', the string has to match the substring exactly, which turns out not to be what you wanted).

                Comment


                  #9
                  Let's get back to basics

                  Here is a website that will allow you to test your Regex.

                  https://regex101.com/

                  Here is a site with cheatsheet of Regex syntax.

                  https://www.rexegg.com/regex-quickstart.html#chars

                  Here is the text String I utilized to test the regex: "Midway was recently added to TV sHows temPa MovIes "

                  The Regex that will identify the wanted terms regardless of case is: \b((?i)(?<!Temp\s)Movies|Sports|TV\sShows|TV\sRecordings)\b

                  In the test, It identified both "TV sHows" and "Movies". This is because Temp did not precede Movies but temPa did. If you delete the a it will find TV sHows only.

                  I think this will work in the long run regardless of text before or after.

                  Comment


                    #10
                    Thank you so much guys. The solution provided by zwolfpack and AllHailJ worked.

                    I generally stay far far away from "Regular" (nothing regular about them) Expression but really needed to use it here.

                    Again, Thank You!
                    RJ_Make On YouTube

                    Comment


                      #11
                      Regularly confusing!! Glad you got it working.

                      Comment

                      Working...
                      X