Jump to content

Recommended Posts

Posted

I'm having a string:

$str='<q1="1234"><q2="3452">'

I want to Replace string between <ql=" and ">

And here is my Script:

$str='<q1="1234"><q2="3452">'
$output = StringRegExpReplace($str, '(<q1=")(.*)(">)', '${1}907605$3')
ConsoleWrite($output)

But it only returns:

<q1="907605">

But what I want is:

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


Help me please. :(:( 

Posted
$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.

  On 3/3/2016 at 8:26 AM, namlunthkl said:

But what I want is:

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

 

Expand  

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!

Posted
  On 3/3/2016 at 9:35 AM, 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')
Expand  

big thanks!!!!!!

Posted (edited)

Sorry, I misunderstood about StringRegExpReplace

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

 

Edited by binhnx
Formatted code

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

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
  • Recently Browsing   0 members

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