Replace text line that starts with/contains a certain word

Hey there team, I’m running into the following issue. I have the following output. So this is just an example, this is wrtten to a text file but there tons of these lines that contain/starts with the word ‘Column’ and it can go from 1 to 100…but i want to replace that line with asterisks, like this “************************” I tried using Replace but the digit at the end remains. Thanks in advance for your help!

Column 1
Name
Susie Q
Birthday
Feb 1, 2020
Email
susy@email.com

HI,

How about the following expression?

Starts with Column

System.Text.RegularExpressions.Regex.Replace(yourString,"^Column.*","******************",System.Text.RegularExpressions.RegexOptions.Multiline)

Contains Column

System.Text.RegularExpressions.Regex.Replace(yourString,"^.*Column.*","******************",System.Text.RegularExpressions.RegexOptions.Multiline)

Regards,

1 Like

@Yoichi you’re the best!!! i want and need to learn regex…how–where did you learn??? :heart_eyes:

ok sorry can i ask one more question please!!! the labels like Name, Birthday and Email can those be bold using regex too?

Basically as regex is for string manipulation, there is no format information.
If you use HTML for example, it might be able to surrounded by B tag like <b>Name</b> using the following expression.

 System.Text.RegularExpressions.Regex.Replace(yourString,"(Name)","<b>$1</b>")

how–where did you learn

Sorry but I’m not very familiar with English regex learning site as my native language is not English. For now, can you check the following topic?

Regards,

1 Like

Thanks as always!!!

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