How to remove the first dot from every line but only if it exists

Soufiane

I have a list of subdomains and I want to remove any dot at the beginning of a line, if there is no dot at the beginning of the line, then it leaves that line untouched.

Like this example:

x8.ext.indeed.com
yk1.ext.indeed.com
za.indeed.com
zera.ext.indeed.com
.envoy.eastus2.qa.notjet.net
.envoy.westus.qa.notjet.net
.nomad.eastus2.qa.notjet.net
.nomad.westus.qa.notjet.net
.notjet.net
.torbit.notjet.net
artifacts.notjet.net
bamf.notjet.net
bamfdb.notjet.net
muratiakos

For cases like this use the line-start reference ^ and the specific dot [.]match with your regexp constraining that to a minimum match +, so altogether your regex will be: ^[.]+

I recommend regex101.com to experiment and try queries out too if you want to see in a highlighted way how this works: https://regex101.com/r/hW63Ab/1/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Remove first and last dot from string if exists

How to remove first char of every line in RichTextBox

How to remove everything in the first column only after dot?

How can I remove the first 23 characters from every line in atom editor?

StringJoiner remove delimeter from first position for every line

remove the first 15 characters from every other line in a file

How can I remove the first whitespace of every line of a file?

I only want to remove quotes from the first line

Remove first character in line from text only if it matches defined character

Remove only first line break

JavaScript - How to remove new line from textarea if no text exists before?

How to remove only the first occurrence of a line in a file using sed

How to remove dotted line in table of contents in first heading only?

How to remove the first three characters from every row in a column in R

How can I remove each line if first symbol after quotation marks is dot?

How to remove every line starting with specific string from log file?

.bat - how to remove "dot" and "dot dot" items from dir command

-replace, how to only match the first dot?

Remove first line from Textarea

Read all lines from TXT file and search only in every FIRST string of each line C#

Keep only the first line from every sequence of consecutive lines matching a pattern

How to remove first line from a String containing XML?

How to remove first line text from text-box?

remove only the first blank line sed

How to remove line `v u` from a file when line `u v` already exists using unix command

How to remove first line of element

How to remove only the first and last characters from a string in Google Sheets

How to remove the first range of lines only from file?

How to remove "//" from csv record on first column only