PDFから読み取ったデータで、不特定のスペースでつながった数字があります。
これを、それぞれの数字に分けたいのですが、不特定数のスペースでの区切りかたがわかりません。
データ見本 ( _ は半角スペース)
_____123_______12,345_____123.45
これを、Split などで 123と12,345と123.45の3つのデータに分けたく、お知恵をいただけないでしょうか?
PDFから読み取ったデータで、不特定のスペースでつながった数字があります。
これを、それぞれの数字に分けたいのですが、不特定数のスペースでの区切りかたがわかりません。
データ見本 ( _ は半角スペース)
_____123_______12,345_____123.45
これを、Split などで 123と12,345と123.45の3つのデータに分けたく、お知恵をいただけないでしょうか?
HI @CaptNob
Welcome to UiPath community
Can you confirm do you need to split three string ?
Split("123 12,345 123.45"," ").ToArray
Split("123 12,345 123.45"," ")(0)
Regards
Gokul
Hi @CaptNob
Welcome To the Community!!
Check out these expressions
Split(System.Text.RegularExpressions.Regex.Replace("_____123_______12,345_____123.45","_+","_"),"_")(1)
Split(System.Text.RegularExpressions.Regex.Replace("_____123_______12,345_____123.45","_+","_"),"_")(2)
Split(System.Text.RegularExpressions.Regex.Replace("_____123_______12,345_____123.45","_+","_"),"_")(3)
If you needed in the array of string use this in your for each and loop through the items
Split(System.Text.RegularExpressions.Regex.Replace("_____123_______12,345_____123.45","_+","_"),"_")
Note: You will receive the first item as empty because your string is starting with “_”
Regards
Sudharsan
You can also try with Regex expression @CaptNob
Value 1 = System.Text.RegularExpressions.Regex.Matches("_____123_______12,345_____123.45","[\d.,]+")(0)
Value 2 = System.Text.RegularExpressions.Regex.Matches("_____123_______12,345_____123.45","[\d.,]+")(1)
Value 3 = System.Text.RegularExpressions.Regex.Matches("_____123_______12,345_____123.45","[\d.,]+")(2)
Regards
Gokul
こんにちは
以下のいずれかいかがでしょうか?
StringSplitOptions.RemoveEmptyEntriesを使う方法
yourString.Split(" "c,StringSplitOptions.RemoveEmptyEntries)
Regex.Splitを使う方法
System.Text.RegularExpressions.Regex.Split(yourString.Trim," +")
Sample20220924-1.zip (3.6 KB)
ありがとうございました。
SPLITでの正規表現もRemoveEmptyEntriesオプションもどちらもうまくいきました。
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.