Search code examples
regexsubstring

Regex to match multiple string conditions


I have a need to capture two different string types returned by a query. The first string has data that needs to be trimmed off while the second string is just text.

Review / Sign Changes  (Doe,John Howard - 555-00-5555)
City & State for Current Visit

I tried

(?\<Group1\>(?:(.)  ())|.\*
(?\<Group1\>\*.\[a-zA-Z\] )|(.\*)

I expected:

Review / Sign Changes
City & State for Current Visit

I'm not strong in Regex but I try :) Any help would be appreciated.


Solution

  • This regex:

    ^[^(]+
    

    Online demo

    The regular expression matches as follows:

    Node Explanation
    ^ the beginning of the string
    [^(]+ any character except: ( (1 or more times (matching the most amount possible))