I have a string, and I would like to extract substring from the start to the first new line character.
the string is
“asd ftr d.o.o.
Brčeva 14b
12387 Ldfeana - Črče”
The resoult should be “asd ftr d.o.o.”
I have a string, and I would like to extract substring from the start to the first new line character.
the string is
“asd ftr d.o.o.
Brčeva 14b
12387 Ldfeana - Črče”
Please try this
Str.Split({Environment.NewLine},StringSplitOptions.RemoveEmptyEntries)(0)
Cheers
hi @tomaz
You can try this expresssion
System.Text.RegularExpressions.Regex.Matches(status,"\S.+")(0)
Regards
Sudharsan
Sorry but this doesn’t work for me. Maby the new line character is diferent.
My resoult is the same as input string.
Example.txt (48 Bytes)
Please try these …these are all the possible new line characters
Str.Split({Environment.NewLine,vbcrlf,"\n","\r\n","\r"},StringSplitOptions.RemoveEmptyEntries)(0)
cheers
cheers
Hi,
How about the following expression?
System.Text.RegularExpressions.Regex.Match(strData,"^.*?(?=\r?\n)").Value
Sample20230104-2aL.zip (2.4 KB)
Regards,
Sorry but this code returns nothing.
Hi,
Did you try the above sample? It reads your sample text file and output the first line.
Regards,
When I try your code it works. but when I try it in my program it returns the whole string.
Hi,
It seems there is no linebreak in your string.
Can you share your exact string as a file using WriteTextFile activity?
Regards,
Example1.txt (73 Bytes)
This is original text
Hi,
Can you try the following?
System.Text.RegularExpressions.Regex.Match(strData,"^[^\r]+").Value
Sample20230104-2aLv2.zip (3.0 KB)
Regards,
Can you pleas help me remove this character?
substringForum.xaml (4.5 KB)
Check this one
Hi,
Linebreak of your string is chr(13) which is old Mac style.
If you need to convert it to Windows style linebreak, the following helps you.
yourString = yourString.Replace(vbCr,vbCrLF)
If you need to remove this line break, the following will work.
yourString = yourString.Replace(vbCr,"")
If the above is not your requirement, can you elaborate?
Regards,
Thank you very much.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.