Author Topic: interactive regular expression tool  (Read 2450 times)

Offline quadz

  • Loquaciously Multiloquent Member
  • ****
  • Posts: 5352
    • View Profile
  • Rated:
interactive regular expression tool
« on: January 25, 2009, 02:19:34 AM »
Hola!

Pretty slick interactive tool for experimenting with regular expressions:

http://www.rubular.com/

Note: though it claims to be tailored toward ruby regular expressions, unless you get into the more esoteric features, ruby regexps are compatible with perl regexps (which are compatible with grep -E or sed).

So don't worry--if you don't currently know the difference between ruby/perl/grep/sed regexps, then what you learn here will most likely be applicable across the board.

Also -- pretty nice example of dynamic HTML on that site...!

Regards,

:beer:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
"He knew all the tricks, dramatic irony, metaphor, bathos, puns, parody, litotes and... satire. He was vicious."

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: interactive regular expression tool
« Reply #1 on: January 26, 2009, 12:53:12 PM »
You could also use something like editpad pro so when you build the regex it highlights all the matches.

Here's matching an IP:
\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b

\b apply regex on word boundry

\.  matches on the literal period, the . will be there in decimal form ip to separate the four bytes

but matching on d{1,3}\. will only verify there is 1 to 3 digits then a period, so it will match 999.999.999.999 , and an ip cannot go passed 255 for the value of each byte since the whole ip address is base2 32 bits.

the patterns inside the paranthesis gets applied to match 0-255 ..[0-5] match a single digit 0 through 5 after 25 before the . in a word boundry.  The ? matches the preceding character zero or more times.  Then you can write them more efficient, and i'm not quiet sure how that works.

Then there is passing the parameters via the bash shell.

anything in the ' quotes is literal except \ when followed by a $ for variables or backticks for embedding a command or something like that, where data between " does expand variables and what not.

Well something like that

 :lolsign:
« Last Edit: January 27, 2009, 11:43:06 AM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline [BTF]Sigma

  • Phenomenally Prodigious Member
  • **
  • Posts: 3059
    • View Profile
  • Rated:
Re: interactive regular expression tool
« Reply #2 on: January 26, 2009, 11:06:39 PM »
Brain = :bomb:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: interactive regular expression tool
« Reply #3 on: January 27, 2009, 08:14:55 AM »
The regular expression can be applied by something like a utility (egrep) that shows  lines in a file that match the pattern.  Certain characters in the expression have special meaning.

Like.
. = any one single character, but only one
the \ makes the character afterwards a literal character "\." is a real period
*,?, [ ] , (), {}, ^, and $ have special meaning to. like ^ is the start of what you apply the regex to, and $ the end.

« Last Edit: January 27, 2009, 09:22:38 AM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

 

El Box de Shoutamente

Last 10 Shouts:

 

Yotematoi

Today at 08:33:15 AM
Yo desde el año 2007 me enfermé de Q2, es incurable  
Morir y revivir es costumbre, lástima q el QT estaba bueno
 

ImperiusDamian

May 12, 2025, 01:45:35 AM
Quake II is not 27 years old. I refuse to accept THAT much time has gone by.
 

|iR|Focalor

May 11, 2025, 02:33:39 PM
 

-Unh0ly-

May 03, 2025, 08:02:46 AM
198.179.6.200:30634
 

Yotematoi

May 02, 2025, 10:27:47 AM
Note for Player-4109 "Remember, the Guinness Book of Records does not include cowards who shot at someone by treachery." :D
 

|iR|Focalor

April 02, 2025, 02:47:07 AM
 

Yotematoi

February 14, 2025, 12:41:48 PM
 :-*
 

|iR|Focalor

February 13, 2025, 07:31:24 AM
I was on DM this morning for the first time in a pretty long time. Seemed fine to me.

0rbisson

February 13, 2025, 04:54:21 AM
DM server is fucked. 2 point blank rockets from spawn and lava damage and player survived? WTF?" Also someone has fucked with the spawn points, every single time no matter how big the map you spawn right in front of the person who killed you last

Show 50 latest
Welcome, Guest. Please login or register.
May 17, 2025, 08:46:49 AM

Login with username, password and session length