Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 2226 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Business and Website Management     Web Hosting and Domain Names :

Php: Want to learn PCRE Syntax

Thread title: Php: Want to learn PCRE Syntax
Closed Thread    
    Thread tools Search this thread Display Modes  
07-14-2007, 11:37 AM
#1
montyauto is offline montyauto
montyauto's Avatar
Status: Junior Member
Join date: Apr 2006
Location:
Expertise:
Software:
 
Posts: 68
iTrader: 0 / 0%
 

montyauto is on a distinguished road

  Old  Php: Want to learn PCRE Syntax

I've been learning the php function which uses a Perl-compatible regular expression syntax like preg_match(), ereg() etc.

The function itself is not difficult to understand but when coming to the pattern syntax like Meta-characters, Pattern Modifiers quite make me headache.

See the example below:


[code:1]preg_match_all("/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x",
"Call 555-1212 or 1-800-555-1212", $phones);[/code:1]
or

[code:1]if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
echo "$regs[3].$regs[2].$regs[1]";[/code:1]

or

[code:1]preg_match_all("|<[^>]+>(.*)</[^>]+>|U",
"<b>example: </b><div align=left>this is a test</div>",
$out, PREG_PATTERN_ORDER);[/code:1]


Is there any resources other than the online php manual providing step by step level preferably with a lot of example to understand better about how to build this pattern from the scratch?

07-14-2007, 11:40 AM
#2
Tom is offline Tom
Tom's Avatar
Status: I Code Things
Join date: Aug 2005
Location: UK
Expertise:
Software:
 
Posts: 1,998
iTrader: 14 / 100%
 

Tom is on a distinguished road

Send a message via MSN to Tom

  Old

Have you tried php.net ?

07-14-2007, 11:43 AM
#3
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

All the info that you'll ever want, and more, on Regular Expressions can be found here:
http://www.regular-expressions.info/
There's a huge amount of information available on there, from the very basics through to explicit, complicated details which likely won't concern you. Go take a look.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed