namlunthkl Posted March 3, 2016 Share Posted March 3, 2016 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. Link to comment Share on other sites More sharing options...
namlunthkl Posted March 3, 2016 Author Share Posted March 3, 2016 Please... I need it now Link to comment Share on other sites More sharing options...
namlunthkl Posted March 3, 2016 Author Share Posted March 3, 2016 UPUP......... Please help!!! Link to comment Share on other sites More sharing options...
binhnx Posted March 3, 2016 Share Posted March 3, 2016 $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') namlunthkl 1 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 More sharing options...
namlunthkl Posted March 3, 2016 Author Share Posted March 3, 2016 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 More sharing options...
namlunthkl Posted March 3, 2016 Author Share Posted March 3, 2016 @binhnx Sorry but your script doesn't work Link to comment Share on other sites More sharing options...
namlunthkl Posted March 3, 2016 Author Share Posted March 3, 2016 @binhnx It only return: 907605907605 Link to comment Share on other sites More sharing options...
binhnx Posted March 3, 2016 Share Posted March 3, 2016 (edited) Sorry, I misunderstood about StringRegExpReplace $output = StringRegExpReplace($str, '(<q\d+=")\d*(">)', '${1}907605${2}') Edited March 3, 2016 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! Link to comment Share on other sites More sharing options...
namlunthkl Posted March 3, 2016 Author Share Posted March 3, 2016 1 minute ago, binhnx said: Sorry, I misunderstand about StringRegExpReplace $output = StringRegExpReplace($str, '(<q\d+=")\d*(">)', '${1}907605${2}') @binhnx Please message with me Link to comment Share on other sites More sharing options...
jguinch Posted March 3, 2016 Share Posted March 3, 2016 StringRegExpReplace($str, '(<q\d+=")(.*?)(">)', '${1}907605$3') ; note the "?" after ".*" (look at the StringRegExp help page) or StringRegExpReplace($str, '<q\d+="\K[^"]+(?=")', '907605') binhnx 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now