Answer the question
In order to leave comments, you need to log in
How to remove a piece of a string after a certain character?
Good afternoon, please help, it is necessary to remove the characters after the # sign in the xml file. The number of characters is always the same.
Example:
<ID>df1eaa47-6d9b-11e1-8016-000e0c4358bd#efc75a38-1e91-11e7-aacc-001d607884abID>
You need to remove the characters after # (including #) to get this:
<ID>df1eaa47-6d9b-11e1-8016- 000e0c4358bdID>
$str = Get-Content ''
$str.Split("ID>")[-1]
But that's not correct
Answer the question
In order to leave comments, you need to log in
$obj = "<Ид>df1eaa47-6d9b-11e1-8016-000e0c4358bd#efc75a38-1e91-11e7-aacc-001d607884abИд>"
([regex]::matches($obj,"(<Ид>.*)#.*"))[0].groups[1].value + "Ид>"
$str = '<Ид>df1eaa47-6d9b-11e1-8016-000e0c4358bd#efc75a38-1e91-11e7-aacc-001d607884abИд>'
$str = $str.remove($str.indexof('#'))+"Ид>"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question