Solved

Help with preg_match regular expression

Posted on 2009-05-04
4
280 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

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 (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  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