Page 1 of 1

Resource for RegEx

Posted: Mon Feb 18, 2008 12:12 am
by localmotion34
Where is a good resource to find regular expression for renaming files, striping strings within strings ect?

i have found a few:

Code: Select all

RemoveBrackets.s="(?Ex) [\{\(\[\]\}\)] "
RemoveBracketContents.s="(?Ex) [\{\(\[]+.*?[\]\}\)]+ "
ChangeToSingleDash.s="(?x) [\-]+ "
RemoveNumbers.s="(?x)[0-9] "
Where would one go to find other preformed RegEx like these?

Posted: Mon Feb 18, 2008 10:55 am
by Comtois
http://www.regular-expressions.info/examples.html

You can find

matching IP adress
Matching Floating Point Numbers
Matching Email adress
Etc

Posted: Mon Feb 18, 2008 10:59 am
by gnozal
And here are some pb examples [german] :
http://www.purebasic-lounge.com/viewtopic.php?t=4994

Posted: Tue Feb 19, 2008 11:00 pm
by localmotion34
What flavor of REgEx is the PB library based on?

I have an evaluation copy of RegexBuddy, which lists something like 12 different types of libraries.

i have found some good ones in .Net too. Most of the ones i have found work in almost all cases, but some do not.

So what do we have with PB? does it support multiple?

Posted: Tue Feb 19, 2008 11:47 pm
by hallodri

Posted: Wed Feb 20, 2008 12:22 am
by localmotion34
thanks for the tip!

here are some good ones I found so far, and ALL work with PCRE and have been tested in REgExBuddy:

Code: Select all

RemoveBrackets.s="[\{\(\[\]\}\)]"
BracketContents.s="[\{\(\[]+.*?[\]\}\)]+"
MultipleDash.s="(?x) [\-]+"
RemoveNumbers.s="(?x)[0-9] "
RemoveZeros.s= "[0]+([0-9]+)"
CopyOf.s="(?:Copy (?:\(\d*\) )*of )"
CopyOf2.s="Copy \d+\w+ of"
FileExtension.s="(?x)[.].{3,3}$"
AlphaNumeric.s="(?x)[~@#$%^&;=]"
EmailAddress.s="([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)"
EmailAddress2.s="([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})"
EmailAddress3.s="\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b"
SocialSecurityNum.s="\d{3}-\d{2}-\d{4}"
IPAddress.s="\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"
IPAddress2.s="\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"

Re: Resource for RegEx

Posted: Sat May 21, 2011 11:11 pm
by siesit
how to remove all\any HTML tags?