Jump to content

Recommended Posts

Posted

I have such snippet:
 

_Example()

Func _Example()
    Local $sText = '"10.9"'
    MsgBox(0, '',  _
    StringRegExpReplace($sText,'("\d+\.)(\d)(")','$1$20$3') _
    )
EndFunc

I was trying to add 0 after 9.
I know that $20 is treated as group #20 not as group #2 and zero.

My question is:
How to insert 0 between $2 and $3 ?

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

@mLipok

  Quote

Remarks

To separate back-reference replacements from actual (replaced) numbers, wrap them with curly braces, i.e: "${1}5".

Expand  

So:

_Example()

Func _Example()
    Local $sText = '"10.9"'
    MsgBox(0, '', StringRegExpReplace($sText,'("\d+\.)(\d)(")','$1${2}0$3'))
EndFunc

Maybe a StringFormat could be more appropriate? :)

Click here to see my signature:

  Reveal hidden contents

 

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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