How to: Remove text from the start or end of a line

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

User avatar
DataMystic Support
Site Admin
Posts: 2154
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

How to: Remove text from the start or end of a line

Postby DataMystic Support » 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

Code: Select all

[lineStart]aaa

Replace with nothing. Note that literal text 'aaa' appears outside the [] EasyPattern brackets, but could also be written as:

Code: Select all

[lineStart, 'aaa' ]


To remove indentation (one or more white space characters at the start of the line), use

Code: Select all

[lineStart, longest 1+ tab or space or verticalTab ]
or

Code: Select all

[lineStart, longest 1+ whitespace ]

Replace with nothing.

To remove one or more > characters (like in an email reply), use

Code: Select all

[lineStart, longest 1+ space or tab or '>' ]

Replace with nothing.

To remove one or more numbers (e.g. line numbers), use

Code: Select all

[lineStart, longest 1+ digits ]
or

Code: Select all

[lineStart, longest 1+ digits or '.' 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

Code: Select all

[lineEnd]###

Replace with nothing.

To remove one or more white space characters at the end of the line, use

Code: Select all

[ 1+ tab or space, lineEnd ]
or

Code: Select all

[ 1+ whitespace, lineEnd ]

Replace with nothing.

To remove one or more numbers (e.g. line numbers), use

Code: Select all

[ 1+ digits, lineEnd ]
or

Code: Select all

[ 1+ digits or '.' or '$', lineEnd ]

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 7 guests