Solved

Help with preg_match regular expression

Posted on 2009-05-04
4
283 Views
Last Modified: 2012-08-13
Please check the regular expression and modify it if it needs tweaking.

ORIGINAL:

$array = array('marker1start', 4, 5, 6, 'marker1end')

preg_match('/^marker(\d+)start$/i', $value, $matches)


NEW (appended .txt to marker strings in $array):

$array = array('marker1start.txt', 4, 5, 6, 'marker1end.txt')

preg_match('/^marker(\d+)start$/i', $value, $matches)
0
Comment
Question by:fcqmax
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:Terry Woods
ID: 24300850
Is this what you're looking for?

$array = array('marker1start.txt', 4, 5, 6, 'marker1end.txt')

preg_match('/^marker(\d+)start\.txt$/i', $value, $matches)
0
 

Author Comment

by:fcqmax
ID: 24300946
Sorry, my array strings were wrong, here is the correct version:

$array = array('text/marker1start.txt', 4, 5, 6, 'text/marker1end.txt')

preg_match('/^marker(\d+)start$/i', $value, $matches)
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 24300983
Try this then:

$array = array('text/marker1start.txt', 4, 5, 6, 'text/marker1end.txt')

preg_match('/^text\/marker(\d+)start\.txt$/i', $value, $matches)
0
 

Author Closing Comment

by:fcqmax
ID: 31577842
Great!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question