B@T Posted June 21, 2010 Report Share Posted June 21, 2010 (edited) I tried to make a regular expression with a backslash in it. For example: {file:regex:[^\\].*$} should return the filename from a filepath. But if i put the backslash in the regular expression, it returns an empty string. Edited June 21, 2010 by B@T Link to comment Share on other sites More sharing options...
CybTekSol Posted June 21, 2010 Report Share Posted June 21, 2010 Try escaping it with two forward slashes // if I recall correctly. Link to comment Share on other sites More sharing options...
B@T Posted June 22, 2010 Author Report Share Posted June 22, 2010 (edited) I'm not sure how should I try. I tried [^/\]*$ and [^/\/\]*$ but these didn't work. Could you post me an example? Edited August 1, 2010 by B@T Link to comment Share on other sites More sharing options...
andreone Posted June 22, 2010 Report Share Posted June 22, 2010 I'm not sure how I should try. I tried [^/\]*$ and [^/\/\]*$ but these didn't work. Could you post me an example? Did you try //\ Link to comment Share on other sites More sharing options...
B@T Posted June 22, 2010 Author Report Share Posted June 22, 2010 [^//\]*$ and [^//\\]*$ are not working, too. Link to comment Share on other sites More sharing options...
shawn Posted June 23, 2010 Report Share Posted June 23, 2010 I don't think it's your escaping that is the problem, but the rest of the regex pattern. Try this: {file:regex:[^\\]+$} Link to comment Share on other sites More sharing options...
B@T Posted June 23, 2010 Author Report Share Posted June 23, 2010 No, still not working with + instead of *. Link to comment Share on other sites More sharing options...
CybTekSol Posted July 5, 2010 Report Share Posted July 5, 2010 I think I had the two forward slashes in my previous post confused with two backslashes ( \\ )... Try two backslashes ( \\ ) with EACH backslash you use... in other words... 3 backslashes will make 1 backslash in regex. Link to comment Share on other sites More sharing options...
floele Posted July 8, 2010 Report Share Posted July 8, 2010 Easier would probably be to use the "filename" function. {file:filename} Link to comment Share on other sites More sharing options...
B@T Posted August 1, 2010 Author Report Share Posted August 1, 2010 I tried 3 backslashes as CybTekSol suggested, but it's not working too. floele, well, it's a perfect workaround, but i think in the bugs topic, we prefer concentrate on the problem which demonstrated by the example. Oh, and i tried some other regexp patterns, and i also can't use colon in it, because Ketarin thinks, it's a separator, and i can't escape it with backslash(es). Link to comment Share on other sites More sharing options...
shawn Posted August 4, 2010 Report Share Posted August 4, 2010 B@T, I think you're using a flawed assumption. My understanding was that from a variable with a value like this "c:\user\me\stuff\files.txt" you were trying to return only "files.txt". By default, Regex isn't multiline, so an exclusion ([^\\]) wouldn't return anything if your variable had a carriage return or line feed within it. Consider passing it thru a "trim" before you attempt the regex grab. Or, alternatively, use optional carriage return/line feeds as possible terminators in the grab: {file:regex:[^\\]+[\r\n\s\t]*$} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now