Jump to content

replacing text when


gcue
 Share

Recommended Posts

hello world

i am trying to replace the text "(see section B)"  with '(<font color="FF8300">see section B2</font>)' - the trick is B might be different combination of letters and numbers

$action_item = "(see section B)"
$action_item = StringRegExpReplace($action_item, "(see section [\d])", '(<font color="FF8300">see section [\d]</font>')

thank you for your help and this working example would be very helpful for future cases :)

Edited by gcue
Link to comment
Share on other sites

For fun 🤣 Because I was stupid, so I only knew how to do that :(

#include <String.au3>
Global $iString0 = "(see section B)"
Global $iString1 = "see section"
Global $iString2 = ")"
Global $iStringX = '(<font color="FF8300">'
Global $iStringY = '</font>)'
Global $StringK, $StringOUT
Global $aRet = _StringBetween($iString0, "(" & $iString1, $iString2)
If IsArray($aRet) Then
    $StringK = $aRet[0]
    $StringOUT = $iStringX & $iString1 & $StringK & $iStringY
    MsgBox(64 + 262144, $StringK, $StringOUT)
EndIf

 

Regards,
 

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