Help with preg_match regular expression

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


$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)
Question by:fcqmax
  • 2
  • 2
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)

Author Comment

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)
LVL 35

Accepted Solution

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)

Author Closing Comment

ID: 31577842

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
Introduction This article is intended for those who are new to PHP error handling (  It addresses one of the most common problems that plague beginning PHP develop…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

803 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