Friday

variables in dot net regular expressions

search pattern :  \s*<Merchant>\s*<ID>(?'d'.*?)</ID>
replace pattern:
NF:${d}.xml
<Merchant>
        <ID>${d}</ID>


As you can see d is variable declared in  search pattern and used into replace:
Also here is interpretation of search pattern :
Options: dot matches newline; free-spacing

Match a single character that is a “whitespace character” (spaces, tabs, line breaks, etc.) «\s*»
   Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the characters “<Merchant>” literally «<Merchant>»
Match a single character that is a “whitespace character” (spaces, tabs, line breaks, etc.) «\s*»
   Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the characters “<ID>” literally «<ID>»
Match the regular expression below and capture its match into backreference with name “d” «(?'d'.*?)»
   Match any single character «.*?»
      Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match the characters “</ID>” literally «</ID>»




No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...