Solved

php reg match

Posted on 2011-09-08
9
269 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

13 Experts available now in Live!

Get 1:1 Help Now