Topic: I am sure this is a REGEX beginner question (1 of 5), Read 80 times
Conf: Search and Replace
From: Frederick Goodrum
Date: Tuesday, August 16, 2005 08:22 AM

I apologize in advance. But Regex is confusing me as I use Search/Replace infrequently.
Throughout out my file I would like to replace all occurrences of text between a colon and vertical line with just just a vertical line. As I read the help and a regular expression book I come up with the following search string

:.\| - Search for all between colon and Vert Bar
| - Replace with Vert bar

I am asking for any guidance for what I clearly do not understand.

Fred Goodrum

 


Topic: I am sure this is a REGEX beginner question (2 of 5), Read 80 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Tuesday, August 16, 2005 08:39 AM

>I would like to replace all occurrences of text
>between a colon and vertical line with just just a vertical line..

This is not an exact answer to your question, but might do what you have in mind.

Provided your search string is in a single line, you can do a simple
pattern search / replace:


search: ;|*| (i.e., everything between ";" and "|"
replace: ;|||



This will result in ";||"; if the intended result is ";|" simply leave
out one of the "|" (btw, the first "|" in the replacement string is
the pattern matching code for "|", cf. the help file s.v. pattern
matching codes).

If your search string is not in a single line, have you
considered a simple macro solution?

Fritz

 


Topic: I am sure this is a REGEX beginner question (3 of 5), Read 75 times
Conf: Search and Replace
From: Frederick Goodrum
Date: Tuesday, August 16, 2005 02:46 PM

Thank you! Your suggestion worked like a charm. Hopefully, I can come back to understanding Regex better in the future. It looks like a whole new discipline in and of itself.

 


Topic: I am sure this is a REGEX beginner question (4 of 5), Read 77 times
Conf: Search and Replace
From: Christian Ziemski
Date: Tuesday, August 16, 2005 04:17 PM

On Tue, 16 Aug 2005 08:22:00 -0400, Frederick Goodrum wrote:

>[Regex Search/Replace]
>Throughout out my file I would like to replace all occurrences
>of text between a colon and vertical line with just just
>a vertical line. As I read the help and a regular expression
>book I come up with the following search string
>
> :.\| - Search for all between colon and Vert Bar
> | - Replace with Vert bar

Your search string is almost ready, only a single character is missing:

It should read

:.*\|

The asterisk matches zero or more occurrences of the preceding character, the dot. And the dot matches any character.

Fritz' solution is the same, using pattern matching instead of regular expressions.


Christian

 


Topic: I am sure this is a REGEX beginner question (5 of 5), Read 78 times
Conf: Search and Replace
From: Frederick Goodrum
Date: Tuesday, August 16, 2005 04:43 PM

Thank you for the response and the explanation.