I have string like below:
string:
"//cXML/Request/OrderRequest/ItemOut[]/ItemDetail/Extrinsic[]/home/idea[]"
if I seperate the string with "[]" then the output should be like this
output:
//cXML/Request/OrderRequest/ItemOut[]
/ItemDetail/Extrinsic[]
/home/idea[]
Some times my string like this below also:
string: "//cXML/Request/OrderRequest/ItemOut[]/@quantity"
Then out put should be like below
Output:
//cXML/Request/OrderRequest/ItemOut[]
/@quantity
How about:
Regex.Split(str, "(?<=\[])(?=.)");
This will include the []
in the split results.
Try this.
Dim s As String = "//cXML/Request/OrderRequest/ItemOut[]/ItemDetail/Extrinsic[]/home/idea[]"
Dim results() As String = Regex.Split(s, "\\[]")
For Each s1 As String In results
Console.WriteLine(s1)
Next
To include the delimiter, append it in the split result
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.