Strings to E_REG replace Convertor?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Strings to E_REG replace Convertor?

Post 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
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post 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
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

holy crap - i think that would be a tough script to write!
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post 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
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

I would think that even if it was out there, the resulting expression would be real ugly, like html from WYSIWYG editors
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

yeah, absolutely, this is what i thought

just wishful thinking
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post 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!
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post 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:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply