replace blocks of words starting and ending with x and y
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 7
- Joined: Wed Apr 16, 2008 12:40 pm
replace blocks of words starting and ending with x and y
I am trying to do a Replace All. I need to remove all sections with certain words.
Starting word is START (a bunch of words which vary) and ending word is END
Example:
1234 START more words END 123
1234 START xyz END 123
textpad is fun START abc END la la la
Starting word is START (a bunch of words which vary) and ending word is END
Example:
1234 START more words END 123
1234 START xyz END 123
textpad is fun START abc END la la la
I'm not sure if i understand what you want to replace/remove, but with a further explanation it would be easier to give you an exact example.
But if you want to remove/replace everything between START and END including START/END you could search for "START.+END ?" (there is a space before ?) and replace with something or nothing. If you want to keep START/END, but remove everything between them you could search for "(START).+(END)" and replace with "\1 \2". That will keep START and END with a space between them. The quotation marks should not be included in the search string.
There are other ways as well and maybe a better way to do this, but then some more info would be nice to know exactly what you want. Regular expression must be checked of course.
But if you want to remove/replace everything between START and END including START/END you could search for "START.+END ?" (there is a space before ?) and replace with something or nothing. If you want to keep START/END, but remove everything between them you could search for "(START).+(END)" and replace with "\1 \2". That will keep START and END with a space between them. The quotation marks should not be included in the search string.
There are other ways as well and maybe a better way to do this, but then some more info would be nice to know exactly what you want. Regular expression must be checked of course.
Last edited by gan on Wed Apr 16, 2008 1:54 pm, edited 2 times in total.
-
- Posts: 7
- Joined: Wed Apr 16, 2008 12:40 pm
didn't work
Gan,
That doesn't work. You understand correctly what I am trying to do. I am trying to remove everything including start & end.
I am typing in the "Find What" box: START.+END
The error says "cannot find regular expression.
Thanks,
Kevin
That doesn't work. You understand correctly what I am trying to do. I am trying to remove everything including start & end.
I am typing in the "Find What" box: START.+END
The error says "cannot find regular expression.
Thanks,
Kevin
I just edited my post with a few changes so you could read it once more, but are you sure the cursor is located correctly? If the cursor is at the end of the file and you do a seach "Down" there will be no hits and the same if at the beginning and search "Up". Also make sure you don't have Match case checked unless what you search for have the same case. I also have "POSIX regular expression syntax" enabled, but that shouldn't matter. It works fine for me using Textpad 5.2 and the 3 lines you gave as an example.
-
- Posts: 7
- Joined: Wed Apr 16, 2008 12:40 pm
still doesn't work
START.+END ? (no quotes) Searching up or down will not find regular expression.
-Kevin
-Kevin
-
- Posts: 24
- Joined: Wed Oct 01, 2003 2:24 pm
- Location: United Kingdom
- Contact:
This works for your example
This works for your example:
becameYou could easily follow it with find two spaces and replace by a single space.
Code: Select all
START.*END
Code: Select all
1234 START more words END 123
1234 START xyz END 123
textpad is fun START abc END la la la
Code: Select all
1234 123
1234 123
textpad is fun la la la
Best regards,
David F Haslam, MA, CEng, MIEE
David F Haslam, MA, CEng, MIEE
What version of textpad do you use?
Does any regular expression work? Like a search for "." (should match all characters) or a search for "^.+" or "^.*" (should match all lines).
This is pretty basic usage of regular expression and don't understand why it doesn't work. I assume searching without regular expression work fine.
Does any regular expression work? Like a search for "." (should match all characters) or a search for "^.+" or "^.*" (should match all lines).
This is pretty basic usage of regular expression and don't understand why it doesn't work. I assume searching without regular expression work fine.
-
- Posts: 24
- Joined: Wed Oct 01, 2003 2:24 pm
- Location: United Kingdom
- Contact:
Version
I am using v4.7.3 and have no plan to upgrade to version 5.2
Best regards,
David F Haslam, MA, CEng, MIEE
David F Haslam, MA, CEng, MIEE
Re: This works for your example
Search forDavid Haslam wrote:This works for your example:Code: Select all
START.*END
becameCode: Select all
1234 START more words END 123 1234 START xyz END 123 textpad is fun START abc END la la la
You could easily follow it with find two spaces and replace by a single space.Code: Select all
1234 123 1234 123 textpad is fun la la la
Code: Select all
START.*END ?
Last edited by gan on Wed Apr 16, 2008 2:53 pm, edited 1 time in total.
-
- Posts: 24
- Joined: Wed Oct 01, 2003 2:24 pm
- Location: United Kingdom
- Contact:
I agree that using star plus gave the same bug
I agree.gave same symptoms even in TP 4.7.3
Code: Select all
START.+END
Best regards,
David F Haslam, MA, CEng, MIEE
David F Haslam, MA, CEng, MIEE
Re: I agree that using star plus gave the same bug
So you got it working using TP 4.7.3? Do you have any tips why it doesn't work for jesuslives? I cannot think of any reason why it's working for you and me, but not jesuslives.David Haslam wrote:I agree.gave same symptoms even in TP 4.7.3Code: Select all
START.+END
-
- Posts: 7
- Joined: Wed Apr 16, 2008 12:40 pm
duh....
I think I just upgraded unecessarily.
My end string is \fs28. I can key off of s28 but it seems to have a problem going across multiple lines. It works fine as long as they are on the same line.
The real END string is preceded by a backslash.
START CREATIONTIME='2002-10-10T16:13:46' LASTMODIFIEDTIME='2002-11-29T17:27\f5\fs28\cf0\b\protect
My end string is \fs28. I can key off of s28 but it seems to have a problem going across multiple lines. It works fine as long as they are on the same line.
The real END string is preceded by a backslash.
START CREATIONTIME='2002-10-10T16:13:46' LASTMODIFIEDTIME='2002-11-29T17:27\f5\fs28\cf0\b\protect
Re: duh....
Well then i understand why it wasn't working. Your first example (the 3 lines) isn't even close to the real data since the end string is different, there is no spaces and it might go across more then a single line. With regular expressions it's important to get a accurate example to be able to give you a working search pattern.jesuslives wrote:I think I just upgraded unecessarily.
My end string is \fs28. I can key off of s28 but it seems to have a problem going across multiple lines. It works fine as long as they are on the same line.
The real END string is preceded by a backslash.
START CREATIONTIME='2002-10-10T16:13:46' LASTMODIFIEDTIME='2002-11-29T17:27\f5\fs28\cf0\b\protect
Could you provide a more accurate example with a few lines where you also include an example that goes across more then one line? Then it could be possible to give you a working search pattern. Does it ever cross more then two lines? Is START always at the beginning of the line?
Using regular expression searching for a double backslash "\" will match a single backslash "".
-
- Posts: 7
- Joined: Wed Apr 16, 2008 12:40 pm
real sample
OK, sorry about that. Here is the exact text:
I need to remove all of this text and place a carriage return after fs28.
-Thanks
CREATIONTIME='2002-10-10T16:13:46' LASTMODIFIEDTIME='2002-11-29T17:27:05' SCOPE='<FormScope><Modality>CR</Modality><BodyPart>CSPINE</BodyPart><BodyPart>SPINE</BodyPart></FormScope>'
TEXTFORMAT='4' TEXT='{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss Arial;}{\f3\froman Times New Roman;}{\f4\fswiss\fprq2 System;}{\f5\froman\fprq2 Times New Roman;}}
{\colortbl\red0\green0\blue0;\red255\green255\blue255;}
\deflang1033\pard\ri140\plain\f5\fs28\cf0
I need to remove all of this text and place a carriage return after fs28.
-Thanks
CREATIONTIME='2002-10-10T16:13:46' LASTMODIFIEDTIME='2002-11-29T17:27:05' SCOPE='<FormScope><Modality>CR</Modality><BodyPart>CSPINE</BodyPart><BodyPart>SPINE</BodyPart></FormScope>'
TEXTFORMAT='4' TEXT='{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss Arial;}{\f3\froman Times New Roman;}{\f4\fswiss\fprq2 System;}{\f5\froman\fprq2 Times New Roman;}}
{\colortbl\red0\green0\blue0;\red255\green255\blue255;}
\deflang1033\pard\ri140\plain\f5\fs28\cf0
-
- Posts: 7
- Joined: Wed Apr 16, 2008 12:40 pm
....more
I just saw the rest of your questions.
No, the first word to remove is almost never at the start of the line.
-Kevin
No, the first word to remove is almost never at the start of the line.
-Kevin