How to: Remove text from the start or end of a line
Posted: Fri May 13, 2011 11:43 am
Step 1. Add Filters\Replace\Find EasyPattern.
To remove text from the start of the line
Let's say we want to remove 'aaa' from the start of each line, use search text of
Replace with nothing. Note that literal text 'aaa' appears outside the [] EasyPattern brackets, but could also be written as:
To remove indentation (one or more white space characters at the start of the line), use
or
Replace with nothing.
To remove one or more > characters (like in an email reply), use
Replace with nothing.
To remove one or more numbers (e.g. line numbers), use or
Replace with nothing.
Learning: [lineStart] is a position which matches the start of the line or the start of the file.
Literal text is included either inside the EasyPattern brackets inside quotes, or outside the [] EasyPattern brackets.
If we have a repeat at the end of our match (e.g. 1+ spaces) then we must use the keyword longest to force EasyPatterns to find the longest match.
To remove text from the end of the line
Let's say we want to remove '###' from the end of each line, use search text of
Replace with nothing.
To remove one or more white space characters at the end of the line, use or
Replace with nothing.
To remove one or more numbers (e.g. line numbers), use or
Replace with nothing.
Learning: [lineEnd] is a position which matches the end of the line or the end of the file.
We don't need the keyword longest here, because the pattern won't match until it find a lineEnd at the end.
See: http://www.datamystic.com/easypatterns_reference.html
If you have ideas for more 'How To's' please drop a note in the forums or send us an email.
To remove text from the start of the line
Let's say we want to remove 'aaa' from the start of each line, use search text of
Code: Select all
[lineStart]aaa
Code: Select all
[lineStart, 'aaa' ]
Code: Select all
[lineStart, longest 1+ tab or space or verticalTab ]
Code: Select all
[lineStart, longest 1+ whitespace ]
To remove one or more > characters (like in an email reply), use
Code: Select all
[lineStart, longest 1+ space or tab or '>' ]
To remove one or more numbers (e.g. line numbers), use
Code: Select all
[lineStart, longest 1+ digits ]
Code: Select all
[lineStart, longest 1+ digits or '.' or '$' ]
Learning: [lineStart] is a position which matches the start of the line or the start of the file.
Literal text is included either inside the EasyPattern brackets inside quotes, or outside the [] EasyPattern brackets.
If we have a repeat at the end of our match (e.g. 1+ spaces) then we must use the keyword longest to force EasyPatterns to find the longest match.
To remove text from the end of the line
Let's say we want to remove '###' from the end of each line, use search text of
Code: Select all
[lineEnd]###
To remove one or more white space characters at the end of the line, use
Code: Select all
[ 1+ tab or space, lineEnd ]
Code: Select all
[ 1+ whitespace, lineEnd ]
To remove one or more numbers (e.g. line numbers), use
Code: Select all
[ 1+ digits, lineEnd ]
Code: Select all
[ 1+ digits or '.' or '$', lineEnd ]
Learning: [lineEnd] is a position which matches the end of the line or the end of the file.
We don't need the keyword longest here, because the pattern won't match until it find a lineEnd at the end.
See: http://www.datamystic.com/easypatterns_reference.html
If you have ideas for more 'How To's' please drop a note in the forums or send us an email.