Ventura Posted August 11, 2016 Share Posted August 11, 2016 well I don't a thing about regex other than just replacing plain text /: So I have this text <data> <us1></us1> <eu1></eu1> <rt2></rt2> <le2></le2> </data> I want to remove all those text inside the data so I get output like this <data> </data> SO far after searching the forum for hours I have come up with this $sText = "<data><us1><eu1><rt2><le2></data>" Local $sStart = "(\<data>)" Local $sEnd = "(\</data>)" Local $sReplace = ""& @CRLF &"" $Text = StringRegExpReplace($sText, "(?i)" & $sStart & "([^\<]*)" & $sEnd , "$1" & $sReplace & "$3") MsgBox(0, "", $Text) It works only with text inside the data but not after putting several "<>" .. Link to comment Share on other sites More sharing options...
kylomas Posted August 11, 2016 Share Posted August 11, 2016 ventura, ? $sText = '<data1><us1><eu1><rt2><le2></data1>' & @CRLF & '<data2><us2><eu2><rt22><le22></data2>' & @LF & '<data3><us3><eu3><rt23><le23></data3>' $Text = StringRegExpReplace($sText, '(?i)(<data.>)(.*?)(</data.>)', '$1$3') MsgBox(0, "", $Text) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
mikell Posted August 11, 2016 Share Posted August 11, 2016 (?s) option suggested sText = '<data><us1><eu1><rt2><le2></data>' & @CRLF & '<data><us2><eu2><rt22><le22></data>' & @LF & '<data><us3><eu3><rt23><le23></data>' $Text = StringRegExpReplace($sText, '(?is)(?<=<data>)(.*?)(?=</data>)', "") MsgBox(0, "", $Text) 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