Topic awaiting preservation: Your favorite RegEx |
|
---|---|
Author | Thread |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 03-28-2004 18:49
I am looking for a listing of everyones favorite regular expression and a breif description of why. I am going to be adding all your replies to a tutorial I am writing for the GN. So, if you don't want your username, regex and explaination included don't post. That makes things simple. I am going to start it off. |
Bipolar (III) Inmate From: Brisbane |
posted 03-28-2004 22:16
Woohoo, someone's finally writing a regex tutorial for the GN. I think I stuck my hand up to do one of them years ago but never got around to it. Although, I'm a little unsure about that regex. That doesn't match country based domains like .com.au does it? (I just woke up so I could be wrong)... |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 03-28-2004 23:48
I don't have a favorite regex per se but one simple trick is for matching stuff inbetween two delimeters |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 03-29-2004 00:34
Nice one! I like that, and it can be adapted for many other purposes. |
Maniac (V) Mad Scientist From: :morF |
posted 03-29-2004 01:43
I use asylum style BBCode in almost any CMS style system I make, so my favourite regex has to be the one that allows me to hand [url= style tags code: (?Ui)(\[url=)(.*)(\])(.*)(\[\/url\])
|
Bipolar (III) Inmate From: Victoria, BC |
posted 03-29-2004 03:51
My favourite regex would have to be this one that matches and remembers chunks of any valid URL: code: ^((\w*):\/\/)?([^\/]*)\/?(.*)?$
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 03-29-2004 03:52
That is useful too! The reason I wanted this thread above and beyond the use in the tutorial, is that everyone who uses them has one, and they can all be totally different. Many people use things daily that I wouldn't think of using at all. The other thing is that regular expressions can vary so much from person to person. Even things that do the same things can be extremely different. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 03-30-2004 15:56
Abb! I totally missed you regex, you must have posted it while I was posting my response. That is a great regex! Thanks for sharing! |
Maniac (V) Inmate From: out of a sleepy funk |
posted 03-30-2004 22:28
sorry to go OT a bit but I found this several weks ago, have yet to use it but thought it may be of interest and use to anyone checking this thread for cool stuff (hopefully a good piece of tutorware) |
Paranoid (IV) Inmate From: A graveyard of dreams |
posted 03-31-2004 19:22
I often use both the * and the ? to find the files I want, for example *.pdf or chapter1?.pdf. But the one I probably use the most - while editing files in Vim - is the simple /something or /\>anotherthing\>to find every occurance of "something" or the word "anotherthing". code: s/(?<=\d)(?=(\d\d\d)+(?!\d))/,/g
|
Paranoid (IV) Inmate From: France |
posted 03-31-2004 20:18
I'm surprised nobody already talked about that Shakespearian RegEx : |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 04-01-2004 16:43
|
Paranoid (IV) Inmate From: Madison, Indiana, USA |
posted 04-01-2004 18:30
I don't know if I have a favorite. I use regular expressions a lot and have used the following several times recently: |