RabbieBurns Posted April 30, 2014 Posted April 30, 2014 Is there a website or program that will let me convert a text string to it's RegEx equivalent? Google isnt helping me right now...
LosOjos Posted April 30, 2014 Posted April 30, 2014 (edited) Not sure what you mean? A regex string is a text string, it's the format of that string that defines what the regex query finds as a match. Do you mean that you have a string literal which you want to convert to a regex query so that regex returns all matches of that exact string? If the string contains only alphanumeric characters, you don't need to change it. If however it contains special characters (punctuation), then you'll need to escape them, either by placing a backslash before each special character or wrapping the entire string in \Q...\E, i.e. to find "this. is. sparta!" you could wrap it like so: "\Qthis. is. sparta!\E" and regex would treat everything between \Q...\E as literal. EDIT: this website was a god send when I started using regex: http://www.regular-expressions.info/tutorial.html Edited April 30, 2014 by LosOjos
RabbieBurns Posted April 30, 2014 Author Posted April 30, 2014 I mean I want to convert a string of text (a sentence or so) to a REGEX expression that will get matched, and independent of case. I dont really want to have to learn regex, i just want to be able to unput a bunch of words, and it to out put the regex, eg is \ required before a space, or is it a . ? @zag, got a link plz? Google shows a mulititude...
mats Posted May 1, 2014 Posted May 1, 2014 Have a play with Rubular: a Ruby regular expression editor and tester - it's a great tool for helping build regexes.
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