Solved

php reg match

Posted on 2011-09-08
9
271 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

863 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

22 Experts available now in Live!

Get 1:1 Help Now