Let's say I have this string:
set strRegEx to ???
set strResult to find text strRegEx in strTextToSearch with regexp and string result
Here is one solution:
Demo (Note: The
^ in this demo is only added to show multiple examples together; you shouldn't need it.)
.- matches any character
*?- repeats the previous pattern as many times as necessary, but at little as possible ("non-greedy").
match- literal text for the word "match"
(?!...)a negative lookahead; the contained pattern is not included in the result, and cannot be matched.
\.a literal "." (the \ prevents it from being treated as "any character", like above)
Taking into consideration the "case 4" that you've now added, you could perhaps change the regex to:
(?=...)is a positive lookahead.
\/matches a literal "/" character.
$matches the end of the line.
\/|$matches either of the above.