Jump to content

StringRegExpReplace - Problem - Please help!!!


Recommended Posts

$output = StringRegExpReplace($str, '<q\d+="(\d*)">', '907605')

@namlunthkl: There're no need to bump the thread. There're many members but nobody can stay all the times in the forum to answer all the question. Just wait politely.

1 hour ago, namlunthkl said:

But what I want is:

<q1="907605"><q2="907605">

 

If you want replace all the value to a single value, it's easy but you need the right regex pattern

$output = StringRegExpReplace($str, '<q\d+="(\d*)">', '907605')

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

Just now, binhnx said:
$output = StringRegExpReplace($str, '<q\d+="(\d*)">', '907605')

@namlunthkl: There're no need to bump the thread. There're many members but nobody can stay all the times in the forum to answer all the question. Just wait politely.

If you want replace all the value to a single value, it's easy but you need the right regex pattern

$output = StringRegExpReplace($str, '<q\d+="(\d*)">', '907605')

big thanks!!!!!!

Link to comment
Share on other sites

StringRegExpReplace($str, '(<q\d+=")(.*?)(">)', '${1}907605$3') ; note the "?" after ".*" (look at the StringRegExp help page)

or

StringRegExpReplace($str, '<q\d+="\K[^"]+(?=")', '907605')

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...