Solved

php reg match

Posted on 2011-09-08
9
276 Views
Last Modified: 2012-08-14
hello there,
how can I preg match these even when the numbers change?
|1920|1200";</script>

Open in new window

0
Comment
Question by:XK8ER
9 Comments
 
LVL 27

Expert Comment

by:yodercm
ID: 36505578
Why do you want to use preg?  What are you trying to do, there might be a simpler way.
0
 
LVL 1

Author Comment

by:XK8ER
ID: 36505583
because im making a script.
0
 
LVL 2

Expert Comment

by:jnfsmile
ID: 36505617
Well,
/\d{4}/

Open in new window

?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:jnfsmile
ID: 36505634
or, if you meant the whole thing
/\|\d{4}\|\d{4};"\<script\>/

Open in new window

0
 
LVL 1

Author Comment

by:XK8ER
ID: 36505637
/\d{4}/ matched these and its incorrect.

1920|1200";</script>
(e029a7af)";</script>
0
 
LVL 24

Accepted Solution

by:
mankowitz earned 500 total points
ID: 36506356
@infsmile

Just a typo -- you need to include the slash before the word script

The regex you want is:

/\|\d{4}\|\d{4}";\<\/script\>/
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 36506528
What's the result you want? Do you want the 2 numbers separately? If so, you'll want to use preg_match_all
0
 
LVL 1

Author Comment

by:XK8ER
ID: 36507481
you also have to put \ before "
I got it now..
0
 
LVL 1

Author Comment

by:XK8ER
ID: 36507483
this worked
/\|\d{4}\|\d{4}\";\<\/script\>/
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to dynamically set the form action using jQuery.
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 …

860 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