Solved

php reg match

Posted on 2011-09-08
9
272 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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.
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.

773 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