SiobhanElara
asked on
How should I format a regex for a positive lookbehind in ColdFusion?
I have a string that contains a path, like "this/is/a/path/to/the/roo t/subfolde r". I'm attempting to get everything after "root" (in this case "/subfolder".)
According to the documentation at regular-expressions.info, (?<=s)t should match the first "t" in "streets". I used that to make this:
This gives me the error "Reason: Sequence (?<...) not recognized."
I've Googled up a storm and tried escaping characters, changing the parentheses... but the most common error that throws is "?+* follows nothing in expression" with the occasional "Malformed regular expression" "?<="".
I'm at a loss. Can you help? Thanks!
According to the documentation at regular-expressions.info, (?<=s)t should match the first "t" in "streets". I used that to make this:
<cfset regex = "(?<=root).*">
#REFind(regex, myString)#
This gives me the error "Reason: Sequence (?<...) not recognized."
I've Googled up a storm and tried escaping characters, changing the parentheses... but the most common error that throws is "?+* follows nothing in expression" with the occasional "Malformed regular expression" "?<="".
I'm at a loss. Can you help? Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you kaufmed and _agx_! I didn't know that about CF and the lookbehind.
(myselfrandhawa, I might also have something like this/is/a/path/to/the/root /subfolder /and/anoth er, so I can't use ListLast. But thank you for the suggestion!)
(myselfrandhawa, I might also have something like this/is/a/path/to/the/root
<cfset filepath = "this/is/a/path/to/the/roo
<cfset fileName = ListLast(filePath, "/")>