Jump to content

Here is probably the best regex tool


opalelement

Recommended Posts

I know this forum is for REGEX support and not this kind of thing, but this is what I always use for regex and it works great...

 

http://www.gskinner.com/RegExr/

 

It has a match section and a replace section, and it has a whole list of parts you can use, as well as options like case sensitivity. My favorite part is by far that when you hold the mouse over any part in the column or in what you entered, it describes what it is there for.

Link to comment
Share on other sites

I want to see a regex tool where you can enter in the subject, and highlight a portion of it, and it show various ways to express it with regex.  Like for instance, if I were to highlight in this post the word "and" it would show some suggestions with descriptions, like:

 

literal: and

3 letter word: \b\w{3}\b

word starting with 'a' : \ba\w*

 

etc...

Link to comment
Share on other sites

I want to see a regex tool where you can enter in the subject, and highlight a portion of it, and it show various ways to express it with regex.  Like for instance, if I were to highlight in this post the word "and" it would show some suggestions with descriptions, like:

 

literal: and

3 letter word: \b\w{3}\b

word starting with 'a' : \ba\w*

 

etc...

 

You just gave me an idea for a PHP script to make:)

 

Anything you can think of besides the following ways?

...-letters

starts/ends with letter(...)

comes before/after word ...

has this(...) symbol in it

 

Link to comment
Share on other sites

It's admittedly a nice enough looking tool.. yet I feel it is akin to a WYSIWYG editor.

I personally prefer to get my coding hands in there and dirty by manually typing it out and testing from there. Call me old fashioned.

 

bah.  I like the real time highlighting as I type it in. IMO it helps me build a regex faster, because I can see that hey, this thing right here is(n't)? matching what I want it to match - as opposed to having to sort through a long string of whatever nested groups I have, trying to sort out where it went wrong. 

 

 

Link to comment
Share on other sites

It's admittedly a nice enough looking tool.. yet I feel it is akin to a WYSIWYG editor.

I personally prefer to get my coding hands in there and dirty by manually typing it out and testing from there. Call me old fashioned.

 

bah.  I like the real time highlighting as I type it in. IMO it helps me build a regex faster, because I can see that hey, this thing right here is(n't)? matching what I want it to match - as opposed to having to sort through a long string of whatever nested groups I have, trying to sort out where it went wrong.

 

before I found this I would have to make a php script with an example text and then a bunch of replace/match sets and echo them, then look for whichever one matched what I needed.

Link to comment
Share on other sites

I'm mostly not impressed by it because it isn't hard to make something like that.  The 'hardest' part of it is the 'real time' part in which you would have to use some ajax or flash.  You could make something like that completely server side with just a submit button to update, in a few lines of code (minus layout, of course).

Link to comment
Share on other sites

See look.  Not very pretty but a couple lines of code is all it really takes.  Couple more lines of code for multi-colored highlighting (for multiple group captures).  Throw on some ajax for 'realtime' highlighting.  Use some css to make it look pretty. Boom, you're done. 

 

<form action = '' method = 'post'>
Pattern:<br/>
~<input type = 'text' name = 'pattern' size= '55' value = '<?=$_POST['pattern']?>' />~
<input type = 'text' name = 'modifiers' size = '2' value = '<?=$_POST['modifiers']?>' /><br/>
Subject:<br/>
<textarea name = 'subject' cols = '50' rows = '10'><?=$_POST['subject']?></textarea><br/>
<input type = 'submit' value = 'submit'>
</form>

<?php
if ($_POST['pattern'] && $_POST['subject']) {
   $pattern = $_POST['pattern'];
   $subject = $_POST['subject'];
   $m = trim($_POST['modifiers']);
   $hSubject = preg_replace("~$pattern~$m","<font color = 'gray'>|</font><font style='background-color: yellow'>$0</font><font color = 'gray'>|</font>",$subject);
   echo nl2br($hSubject);
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.