MattPage Posted June 2, 2006 Share Posted June 2, 2006 (edited) Hi all, I am trying to write a calculation to make a URL safe string from a field. By URL safe I mean only containing A-Z 0-9 _ and - . I have a PHP script using regexp to do this on the web side but need to convert it to FM. Requirements ------------- Replace one or more spaces with a single "_" Replace one or more & with "_and_" Replace anything not A-Z 0-9 _ with "_" ([^_a-z0-9]+ I've been playing with the Substitute function but it appears I would have to do this individually for every character I dont want, and then check for double (triple, quad..) underscores. Can anyone help with this. Cheers Matt Edited June 2, 2006 by Guest Link to comment Share on other sites More sharing options...
IdealData Posted June 2, 2006 Share Posted June 2, 2006 Sounds like a job for a custom function. Admittedly you will have to allow for all your parameters, but it will simplify the job. Link to comment Share on other sites More sharing options...
John Mark Osborne Posted June 2, 2006 Share Posted June 2, 2006 Yes, you will have to use the Substitute function. I don't see any way to make it easier. Link to comment Share on other sites More sharing options...
MattPage Posted June 2, 2006 Author Share Posted June 2, 2006 Think I sorted it, not perfect but seems to work OK Substitute ( TrimAll ( Filter ( Lower ( text ); "abcdefghijklmnopqrstuvwxyz _-" ); 1; 0); " "; "_") :cofeebrake: Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 6538 days old. Please don't post here. Open a new topic instead.
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