Solved

php reg match

Posted on 2011-09-08
9
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 27

Expert Comment

by:Cornelia Yoder
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
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…

739 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