Page 1 of 1

Strings to E_REG replace Convertor?

Posted: Tue Apr 20, 2004 7:32 am
by malcolmboston
well i was'nt sure were to post this so here goes

was wondering if there was any regex convertors out there, where it would possibly have 2 input fields you fill them in, post it, and it tells you the regex stuff.

Its a long shot, but this stuff always gives me a headache

Mal

Posted: Tue Apr 20, 2004 9:23 am
by Roja
I don't quite follow what it is you want to input.. I think I understand that you want it to output a regex, but could you explain a little more?

Posted: Tue Apr 20, 2004 9:25 am
by malcolmboston
ok say i want 2 create a ereg_replace "string" there would be a web page with 2 inputs
1 - before replace
2 - after replace

you post whats in the input and it tells you the reg ex for that replace

im probably explaining it crap

Posted: Tue Apr 20, 2004 9:29 am
by magicrobotmonkey
holy crap - i think that would be a tough script to write!

Posted: Tue Apr 20, 2004 9:36 am
by malcolmboston
yeah i know

but i thought maybe because its such a complex subject, that gives many people problems

someone may of written it, ive search and to no avail

Mal

Posted: Tue Apr 20, 2004 9:37 am
by magicrobotmonkey
I would think that even if it was out there, the resulting expression would be real ugly, like html from WYSIWYG editors

Posted: Tue Apr 20, 2004 9:38 am
by Roja
magicrobotmonkey wrote:holy crap - i think that would be a tough script to write!
Yeah, unfortunately it would be either wholly over-matching, or very hard to write.

For example, lets say the input was:

"CHeeSe11"

and the output was "chs", then there are a number of ways that could be interpreted..

Are we stripping the letter "e"? Are we stripping all vowels?

Are we removing all numbers, only the number 11, or any instance of "1"?

Are we removing the 3rd, 4th, 6th, 7th, and 8th characters in any string, or is that just a coincidence?

Are we removing characters that are lowercase and numbers, or just lowercase, and certain numbers?

There are literally thousands of combinations to consider.

While I do beleive that in time, an army of monkeys could pound out a script that would do such a thing, I don't beleive anyone has yet.

It is far more effective to either learn regex, or ask on a case-by-case basis.

Posted: Tue Apr 20, 2004 9:40 am
by malcolmboston
yeah, absolutely, this is what i thought

just wishful thinking

Posted: Tue Apr 20, 2004 10:30 am
by redmonkey
If you know the input and you know the output, then just replace the in with the out.

To do what you want, you would need to be able to give the app a pattern definition of the expected output based on the input, which incase you haven't realised yet is in fact regex, so you are right back where you started from.

The simple answer is learn regex!

Posted: Tue Apr 20, 2004 11:42 am
by McGruff
Working away from home so don't have my bookmarks. Try a google for "the regex coach". Doesn't quite do what you asked for but it's very useful for testing & perfecting expressions.

Posted: Tue Apr 20, 2004 11:45 am
by malcolmboston
redmonkey wrote:If you know the input and you know the output, then just replace the in with the out.

To do what you want, you would need to be able to give the app a pattern definition of the expected output based on the input, which incase you haven't realised yet is in fact regex, so you are right back where you started from.

The simple answer is learn regex!
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:

Posted: Tue Apr 20, 2004 3:59 pm
by feyd
one way to "verify" which direction to go in it could be done with multiple examples of inputs and outputs. Another is allowing the user to set flags, like "use 1) alphanumerics 2) alpha 2) numbers 3) character position."

It's a tough subject because, like Roja alluded to, the context in which the person asking for the response varies wildly.