Resource for RegEx

Everything else that doesn't fall into one of the other PB categories.
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Resource for RegEx

Post 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?

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

http://www.regular-expressions.info/examples.html

You can find

matching IP adress
Matching Floating Point Numbers
Matching Email adress
Etc
Please correct my english
http://purebasic.developpez.com/
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

And here are some pb examples [german] :
http://www.purebasic-lounge.com/viewtopic.php?t=4994
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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?

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Post by hallodri »

localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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"

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
siesit
User
User
Posts: 12
Joined: Fri Aug 21, 2009 8:40 am
Location: rus
Contact:

Re: Resource for RegEx

Post by siesit »

how to remove all\any HTML tags?
site created by purebasic work-flow-Initiative
Post Reply