Hi, anyone knows if there is a way to convert an input string into a Regular Expression??
There's no generic way to do that. There are innumerable regexes that would match that string.
Alex Loaiza
Greenhorn
Joined: Jul 22, 2005
Posts: 12
posted
0
Well, in fact, what I need is: given a certain String verify if it is an alfanumeric string and covert it into a Reggex pattern like this [0-9\w], or if it is a numeric (numbers only) string convert it to [0-9]...
Now, if you had a bunch of strings, you can imagine a tool that would create the simplest possible regexp that matched them all. I'm sure such a thing has been done by someone... and indeed, I Googled for "regexp generator" and "regular expression generator" (both in quotes) and both returned many promising hits.
Originally posted by Alex Loaiza: Well, in fact, what I need is: given a certain String verify if it is an alfanumeric string and covert it into a Reggex pattern like this [0-9\w], or if it is a numeric (numbers only) string convert it to [0-9]...
Then why didn't your example convert the "com" at the end?
Alex Loaiza
Greenhorn
Joined: Jul 22, 2005
Posts: 12
posted
0
Originally posted by Jeff Albrechtsen:
Then why didn't your example convert the "com" at the end?
Well, maybe I forget that ".com" at the end, but I think that you already understad what I meant. A simple reggex generator that matches in a "generic" way any input string given...
thanks!
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Something simple-minded like this:
[ November 18, 2005: Message edited by: Jeff Albrechtsen ]
Alex Loaiza
Greenhorn
Joined: Jul 22, 2005
Posts: 12
posted
0
That's correct, just that simple!!
Thanks a lot!!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Convert a String into a Regular Expression