Match floating number in powershell



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have a struggle with matching HTML strings with PowerShell. The last two td elements have one integer(1) and floating number(11,793). The number 73480 never changes. This numbers(1 and 11,793) can switch their type(integer<=>floating). When i use [+-]?([0-9]*[.])?[0-9]+ in this case the code is not working. Any idea how to fix it?



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@
[regex]::Match($web,@"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">(w+) </td>
<td align="left">(w+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
</tr>
"@).Groups[1,2,3,4].Value


After I execute the command there is no output(blank result).










share|improve this question



















  • 3





    Those who parse HTML with regexes multiply sorrow. Consider using a proper parser, like HTML Agility Pack -- PowerShell supports everything .NET can load.

    – Jeroen Mostert
    Nov 15 '18 at 13:05











  • I agree with @JeroenMostert but maybe this is what you're looking for? ([+-]?(([0-9]*[.])|([0-9]*))?[0-9]+)

    – TobyU
    Nov 15 '18 at 13:10











  • There is no output neither with my or your case. Thanks for the sharing HTML Agility Pack way

    – Hristian Yordanov
    Nov 15 '18 at 13:13











  • Your regex looks like you want to make some sort of data validation, but your code looks like you only want to extract the values (something like ([^<]*) would have sufficed for that). So what exactly is it you really want to do?

    – marsze
    Nov 15 '18 at 13:57












  • @marsze I want to get this values from HTML files. This is a part of the file.

    – Hristian Yordanov
    Nov 15 '18 at 13:59

















1















I have a struggle with matching HTML strings with PowerShell. The last two td elements have one integer(1) and floating number(11,793). The number 73480 never changes. This numbers(1 and 11,793) can switch their type(integer<=>floating). When i use [+-]?([0-9]*[.])?[0-9]+ in this case the code is not working. Any idea how to fix it?



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@
[regex]::Match($web,@"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">(w+) </td>
<td align="left">(w+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
</tr>
"@).Groups[1,2,3,4].Value


After I execute the command there is no output(blank result).










share|improve this question



















  • 3





    Those who parse HTML with regexes multiply sorrow. Consider using a proper parser, like HTML Agility Pack -- PowerShell supports everything .NET can load.

    – Jeroen Mostert
    Nov 15 '18 at 13:05











  • I agree with @JeroenMostert but maybe this is what you're looking for? ([+-]?(([0-9]*[.])|([0-9]*))?[0-9]+)

    – TobyU
    Nov 15 '18 at 13:10











  • There is no output neither with my or your case. Thanks for the sharing HTML Agility Pack way

    – Hristian Yordanov
    Nov 15 '18 at 13:13











  • Your regex looks like you want to make some sort of data validation, but your code looks like you only want to extract the values (something like ([^<]*) would have sufficed for that). So what exactly is it you really want to do?

    – marsze
    Nov 15 '18 at 13:57












  • @marsze I want to get this values from HTML files. This is a part of the file.

    – Hristian Yordanov
    Nov 15 '18 at 13:59













1












1








1








I have a struggle with matching HTML strings with PowerShell. The last two td elements have one integer(1) and floating number(11,793). The number 73480 never changes. This numbers(1 and 11,793) can switch their type(integer<=>floating). When i use [+-]?([0-9]*[.])?[0-9]+ in this case the code is not working. Any idea how to fix it?



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@
[regex]::Match($web,@"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">(w+) </td>
<td align="left">(w+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
</tr>
"@).Groups[1,2,3,4].Value


After I execute the command there is no output(blank result).










share|improve this question
















I have a struggle with matching HTML strings with PowerShell. The last two td elements have one integer(1) and floating number(11,793). The number 73480 never changes. This numbers(1 and 11,793) can switch their type(integer<=>floating). When i use [+-]?([0-9]*[.])?[0-9]+ in this case the code is not working. Any idea how to fix it?



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@
[regex]::Match($web,@"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">(w+) </td>
<td align="left">(w+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
<td align="right">([+-]?([0-9]*[.])?[0-9]+) </td>
</tr>
"@).Groups[1,2,3,4].Value


After I execute the command there is no output(blank result).







regex powershell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 13:29







Hristian Yordanov

















asked Nov 15 '18 at 13:03









Hristian YordanovHristian Yordanov

10912




10912







  • 3





    Those who parse HTML with regexes multiply sorrow. Consider using a proper parser, like HTML Agility Pack -- PowerShell supports everything .NET can load.

    – Jeroen Mostert
    Nov 15 '18 at 13:05











  • I agree with @JeroenMostert but maybe this is what you're looking for? ([+-]?(([0-9]*[.])|([0-9]*))?[0-9]+)

    – TobyU
    Nov 15 '18 at 13:10











  • There is no output neither with my or your case. Thanks for the sharing HTML Agility Pack way

    – Hristian Yordanov
    Nov 15 '18 at 13:13











  • Your regex looks like you want to make some sort of data validation, but your code looks like you only want to extract the values (something like ([^<]*) would have sufficed for that). So what exactly is it you really want to do?

    – marsze
    Nov 15 '18 at 13:57












  • @marsze I want to get this values from HTML files. This is a part of the file.

    – Hristian Yordanov
    Nov 15 '18 at 13:59












  • 3





    Those who parse HTML with regexes multiply sorrow. Consider using a proper parser, like HTML Agility Pack -- PowerShell supports everything .NET can load.

    – Jeroen Mostert
    Nov 15 '18 at 13:05











  • I agree with @JeroenMostert but maybe this is what you're looking for? ([+-]?(([0-9]*[.])|([0-9]*))?[0-9]+)

    – TobyU
    Nov 15 '18 at 13:10











  • There is no output neither with my or your case. Thanks for the sharing HTML Agility Pack way

    – Hristian Yordanov
    Nov 15 '18 at 13:13











  • Your regex looks like you want to make some sort of data validation, but your code looks like you only want to extract the values (something like ([^<]*) would have sufficed for that). So what exactly is it you really want to do?

    – marsze
    Nov 15 '18 at 13:57












  • @marsze I want to get this values from HTML files. This is a part of the file.

    – Hristian Yordanov
    Nov 15 '18 at 13:59







3




3





Those who parse HTML with regexes multiply sorrow. Consider using a proper parser, like HTML Agility Pack -- PowerShell supports everything .NET can load.

– Jeroen Mostert
Nov 15 '18 at 13:05





Those who parse HTML with regexes multiply sorrow. Consider using a proper parser, like HTML Agility Pack -- PowerShell supports everything .NET can load.

– Jeroen Mostert
Nov 15 '18 at 13:05













I agree with @JeroenMostert but maybe this is what you're looking for? ([+-]?(([0-9]*[.])|([0-9]*))?[0-9]+)

– TobyU
Nov 15 '18 at 13:10





I agree with @JeroenMostert but maybe this is what you're looking for? ([+-]?(([0-9]*[.])|([0-9]*))?[0-9]+)

– TobyU
Nov 15 '18 at 13:10













There is no output neither with my or your case. Thanks for the sharing HTML Agility Pack way

– Hristian Yordanov
Nov 15 '18 at 13:13





There is no output neither with my or your case. Thanks for the sharing HTML Agility Pack way

– Hristian Yordanov
Nov 15 '18 at 13:13













Your regex looks like you want to make some sort of data validation, but your code looks like you only want to extract the values (something like ([^<]*) would have sufficed for that). So what exactly is it you really want to do?

– marsze
Nov 15 '18 at 13:57






Your regex looks like you want to make some sort of data validation, but your code looks like you only want to extract the values (something like ([^<]*) would have sufficed for that). So what exactly is it you really want to do?

– marsze
Nov 15 '18 at 13:57














@marsze I want to get this values from HTML files. This is a part of the file.

– Hristian Yordanov
Nov 15 '18 at 13:59





@marsze I want to get this values from HTML files. This is a part of the file.

– Hristian Yordanov
Nov 15 '18 at 13:59












2 Answers
2






active

oldest

votes


















1














Your text has a decimal comma but your regex tries to match a [.].

I'd also replace all the multiple spaces in the regex with s*

The groups you select don't count the optional sub(group) catching the first fraction.



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">SampleOne </td>
<td align="left">SampleTwo </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@

$RE = @"
s*<tr bgcolor=#fbf6e9>
s*<td align="center">73480s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*</tr>
"@
[regex]::Match($web,$RE).Groups[1,2,3,5].Value


returns here:



SampleOne
SampleTwo
1
11,793





share|improve this answer























  • Thank you! Can you explain how you see the right group numbering, please? I don't get it...

    – Hristian Yordanov
    Nov 15 '18 at 14:01






  • 1





    The groups are also counting nested pairs of parentheses in order of the opening one (, so Groups[4] is empty as there is no comma following the 1. As you are only interrested in the whole number - simply ignore that sub group. You might use named capture groups to easier identify the proper ones.

    – LotPings
    Nov 15 '18 at 14:09











  • I see. What about if the 1 changes to 1,2? Because the file change this values every day and this number will be changed tomorrow to floating

    – Hristian Yordanov
    Nov 15 '18 at 14:12






  • 1





    Same as with 11,793. As the inner group ([0-9]*[,.])? is optional due to the ? the outer group will hold either condition.

    – LotPings
    Nov 15 '18 at 14:15


















1














Regex parsing is never recommended for HTML.



If your HTML is valid XML (yours is not) you can also parse it as such (for simplicity - if you don't want to include any HTML-parsing libraries):



# (tested in pwsh v5.1)
([xml]'
<tr bgcolor="#fbf6e9">
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
').tr.td | % $_.'#text'.Trim()


Output:




73480

Сазлийка

Гълъбово

1

11,793




(Mind that you have to use quotes for the attribute values to make it valid XML.)






share|improve this answer

























  • I have multiple tables with similar information. The values that I need are the one near 73480

    – Hristian Yordanov
    Nov 16 '18 at 7:25











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320103%2fmatch-floating-number-in-powershell%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Your text has a decimal comma but your regex tries to match a [.].

I'd also replace all the multiple spaces in the regex with s*

The groups you select don't count the optional sub(group) catching the first fraction.



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">SampleOne </td>
<td align="left">SampleTwo </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@

$RE = @"
s*<tr bgcolor=#fbf6e9>
s*<td align="center">73480s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*</tr>
"@
[regex]::Match($web,$RE).Groups[1,2,3,5].Value


returns here:



SampleOne
SampleTwo
1
11,793





share|improve this answer























  • Thank you! Can you explain how you see the right group numbering, please? I don't get it...

    – Hristian Yordanov
    Nov 15 '18 at 14:01






  • 1





    The groups are also counting nested pairs of parentheses in order of the opening one (, so Groups[4] is empty as there is no comma following the 1. As you are only interrested in the whole number - simply ignore that sub group. You might use named capture groups to easier identify the proper ones.

    – LotPings
    Nov 15 '18 at 14:09











  • I see. What about if the 1 changes to 1,2? Because the file change this values every day and this number will be changed tomorrow to floating

    – Hristian Yordanov
    Nov 15 '18 at 14:12






  • 1





    Same as with 11,793. As the inner group ([0-9]*[,.])? is optional due to the ? the outer group will hold either condition.

    – LotPings
    Nov 15 '18 at 14:15















1














Your text has a decimal comma but your regex tries to match a [.].

I'd also replace all the multiple spaces in the regex with s*

The groups you select don't count the optional sub(group) catching the first fraction.



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">SampleOne </td>
<td align="left">SampleTwo </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@

$RE = @"
s*<tr bgcolor=#fbf6e9>
s*<td align="center">73480s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*</tr>
"@
[regex]::Match($web,$RE).Groups[1,2,3,5].Value


returns here:



SampleOne
SampleTwo
1
11,793





share|improve this answer























  • Thank you! Can you explain how you see the right group numbering, please? I don't get it...

    – Hristian Yordanov
    Nov 15 '18 at 14:01






  • 1





    The groups are also counting nested pairs of parentheses in order of the opening one (, so Groups[4] is empty as there is no comma following the 1. As you are only interrested in the whole number - simply ignore that sub group. You might use named capture groups to easier identify the proper ones.

    – LotPings
    Nov 15 '18 at 14:09











  • I see. What about if the 1 changes to 1,2? Because the file change this values every day and this number will be changed tomorrow to floating

    – Hristian Yordanov
    Nov 15 '18 at 14:12






  • 1





    Same as with 11,793. As the inner group ([0-9]*[,.])? is optional due to the ? the outer group will hold either condition.

    – LotPings
    Nov 15 '18 at 14:15













1












1








1







Your text has a decimal comma but your regex tries to match a [.].

I'd also replace all the multiple spaces in the regex with s*

The groups you select don't count the optional sub(group) catching the first fraction.



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">SampleOne </td>
<td align="left">SampleTwo </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@

$RE = @"
s*<tr bgcolor=#fbf6e9>
s*<td align="center">73480s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*</tr>
"@
[regex]::Match($web,$RE).Groups[1,2,3,5].Value


returns here:



SampleOne
SampleTwo
1
11,793





share|improve this answer













Your text has a decimal comma but your regex tries to match a [.].

I'd also replace all the multiple spaces in the regex with s*

The groups you select don't count the optional sub(group) catching the first fraction.



$web = @"
<tr bgcolor=#fbf6e9>
<td align="center">73480 </td>
<td align="left">SampleOne </td>
<td align="left">SampleTwo </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
"@

$RE = @"
s*<tr bgcolor=#fbf6e9>
s*<td align="center">73480s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="left">(w+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*<td align="right">([+-]?([0-9]*[,.])?[0-9]+)s*</td>
s*</tr>
"@
[regex]::Match($web,$RE).Groups[1,2,3,5].Value


returns here:



SampleOne
SampleTwo
1
11,793






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 13:45









LotPingsLotPings

20.6k61633




20.6k61633












  • Thank you! Can you explain how you see the right group numbering, please? I don't get it...

    – Hristian Yordanov
    Nov 15 '18 at 14:01






  • 1





    The groups are also counting nested pairs of parentheses in order of the opening one (, so Groups[4] is empty as there is no comma following the 1. As you are only interrested in the whole number - simply ignore that sub group. You might use named capture groups to easier identify the proper ones.

    – LotPings
    Nov 15 '18 at 14:09











  • I see. What about if the 1 changes to 1,2? Because the file change this values every day and this number will be changed tomorrow to floating

    – Hristian Yordanov
    Nov 15 '18 at 14:12






  • 1





    Same as with 11,793. As the inner group ([0-9]*[,.])? is optional due to the ? the outer group will hold either condition.

    – LotPings
    Nov 15 '18 at 14:15

















  • Thank you! Can you explain how you see the right group numbering, please? I don't get it...

    – Hristian Yordanov
    Nov 15 '18 at 14:01






  • 1





    The groups are also counting nested pairs of parentheses in order of the opening one (, so Groups[4] is empty as there is no comma following the 1. As you are only interrested in the whole number - simply ignore that sub group. You might use named capture groups to easier identify the proper ones.

    – LotPings
    Nov 15 '18 at 14:09











  • I see. What about if the 1 changes to 1,2? Because the file change this values every day and this number will be changed tomorrow to floating

    – Hristian Yordanov
    Nov 15 '18 at 14:12






  • 1





    Same as with 11,793. As the inner group ([0-9]*[,.])? is optional due to the ? the outer group will hold either condition.

    – LotPings
    Nov 15 '18 at 14:15
















Thank you! Can you explain how you see the right group numbering, please? I don't get it...

– Hristian Yordanov
Nov 15 '18 at 14:01





Thank you! Can you explain how you see the right group numbering, please? I don't get it...

– Hristian Yordanov
Nov 15 '18 at 14:01




1




1





The groups are also counting nested pairs of parentheses in order of the opening one (, so Groups[4] is empty as there is no comma following the 1. As you are only interrested in the whole number - simply ignore that sub group. You might use named capture groups to easier identify the proper ones.

– LotPings
Nov 15 '18 at 14:09





The groups are also counting nested pairs of parentheses in order of the opening one (, so Groups[4] is empty as there is no comma following the 1. As you are only interrested in the whole number - simply ignore that sub group. You might use named capture groups to easier identify the proper ones.

– LotPings
Nov 15 '18 at 14:09













I see. What about if the 1 changes to 1,2? Because the file change this values every day and this number will be changed tomorrow to floating

– Hristian Yordanov
Nov 15 '18 at 14:12





I see. What about if the 1 changes to 1,2? Because the file change this values every day and this number will be changed tomorrow to floating

– Hristian Yordanov
Nov 15 '18 at 14:12




1




1





Same as with 11,793. As the inner group ([0-9]*[,.])? is optional due to the ? the outer group will hold either condition.

– LotPings
Nov 15 '18 at 14:15





Same as with 11,793. As the inner group ([0-9]*[,.])? is optional due to the ? the outer group will hold either condition.

– LotPings
Nov 15 '18 at 14:15













1














Regex parsing is never recommended for HTML.



If your HTML is valid XML (yours is not) you can also parse it as such (for simplicity - if you don't want to include any HTML-parsing libraries):



# (tested in pwsh v5.1)
([xml]'
<tr bgcolor="#fbf6e9">
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
').tr.td | % $_.'#text'.Trim()


Output:




73480

Сазлийка

Гълъбово

1

11,793




(Mind that you have to use quotes for the attribute values to make it valid XML.)






share|improve this answer

























  • I have multiple tables with similar information. The values that I need are the one near 73480

    – Hristian Yordanov
    Nov 16 '18 at 7:25















1














Regex parsing is never recommended for HTML.



If your HTML is valid XML (yours is not) you can also parse it as such (for simplicity - if you don't want to include any HTML-parsing libraries):



# (tested in pwsh v5.1)
([xml]'
<tr bgcolor="#fbf6e9">
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
').tr.td | % $_.'#text'.Trim()


Output:




73480

Сазлийка

Гълъбово

1

11,793




(Mind that you have to use quotes for the attribute values to make it valid XML.)






share|improve this answer

























  • I have multiple tables with similar information. The values that I need are the one near 73480

    – Hristian Yordanov
    Nov 16 '18 at 7:25













1












1








1







Regex parsing is never recommended for HTML.



If your HTML is valid XML (yours is not) you can also parse it as such (for simplicity - if you don't want to include any HTML-parsing libraries):



# (tested in pwsh v5.1)
([xml]'
<tr bgcolor="#fbf6e9">
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
').tr.td | % $_.'#text'.Trim()


Output:




73480

Сазлийка

Гълъбово

1

11,793




(Mind that you have to use quotes for the attribute values to make it valid XML.)






share|improve this answer















Regex parsing is never recommended for HTML.



If your HTML is valid XML (yours is not) you can also parse it as such (for simplicity - if you don't want to include any HTML-parsing libraries):



# (tested in pwsh v5.1)
([xml]'
<tr bgcolor="#fbf6e9">
<td align="center">73480 </td>
<td align="left">Сазлийка </td>
<td align="left">Гълъбово </td>
<td align="right">1 </td>
<td align="right">11,793 </td>
</tr>
').tr.td | % $_.'#text'.Trim()


Output:




73480

Сазлийка

Гълъбово

1

11,793




(Mind that you have to use quotes for the attribute values to make it valid XML.)







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 14:02

























answered Nov 15 '18 at 13:49









marszemarsze

5,93132042




5,93132042












  • I have multiple tables with similar information. The values that I need are the one near 73480

    – Hristian Yordanov
    Nov 16 '18 at 7:25

















  • I have multiple tables with similar information. The values that I need are the one near 73480

    – Hristian Yordanov
    Nov 16 '18 at 7:25
















I have multiple tables with similar information. The values that I need are the one near 73480

– Hristian Yordanov
Nov 16 '18 at 7:25





I have multiple tables with similar information. The values that I need are the one near 73480

– Hristian Yordanov
Nov 16 '18 at 7:25

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320103%2fmatch-floating-number-in-powershell%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo