Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Regular Expression - Question regarding pattern matching

$
0
0

Hello together,

I got the following string:

<?xml version="1.0" encoding="UTF-8"?>
<user>
  <user ritaID="METADIR">
    <item desc="RASL Std. GPNR" name="testibus" value="562532525"/>
  </user>
</user>

I ve done the following regex (i know there are easier approaches but I prefered to train some of the more advanced methods):

Why does this regex work properly?

$string -match '(?<!value=)((?<Number>\d+)(?="/>))' 

result : 562532525

but this cuts me off the first part of the number? (value=", instead of value=)

$string -match '(?<!value=")((?<Number>\d+)(?="/>))'
result: 62532525

I am just wondering why because it hasnt dawn on me .. :-)

thanks in advance!


Regards / Freundliche Grüsse King Julien




Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>