How to remove first line from a string variable using regex

Hi iam trying to remove first line from a string variable

actually i try to remove every characters except numbers using this expression “[^\d-.]”

But in my case the variable value includes number in first line like below mentioned

“Column1
20232003”

So any help can be appreciable

Thanks in advance

if it is exactly a line then split by line and use the second part

@jai_kumar2

You can actually use split for it

str.Trim.Split({Environment.NewLine,"\r\n","\n",vbcrlf},2,StringSplitOptions.RemoveEmptyEntries)(1)

cheers

HI,

How about the following expression?

System.Text.RegularExpressions.Regex.Replace(yourString,"^.*\n","")

image

Regards,

HI @jai_kumar2

You can also use this

System.Text.RegularExpressions.Regex.Match(InputString,"\d+").Tostring

This with get you only the numbers

Regards
Sudharsan

Hi @jai_kumar2

How about this Regular expression?

System.Text.RegularExpressions.Regex.Replace(InputString,"\S+\d+\n","")

Regards
Gokul

Dont try above @jai_kumar2

Try this updated one

System.Text.RegularExpressions.Regex.Matches(InputString,"\d+",System.Text.RegularExpressions.RegexOptions.Multiline)(1).ToString

Regards
Sudharsan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.