Solved

Help with preg_match regular expression

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
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 look for a specific file type in a local or remote server directory using PHP.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now