Page 1 of 1
Mark Lines Question
Posted: Fri May 04, 2012 7:56 am
by u20110427
I have a text file with a load of lines on it, e.g.
Code: Select all
CODE-12345asd THIS AND THAT SOMETHING
CODE-12345sassasa 1 RAND BLOB STUFF AND THAT AND SOMETHING ELSE
CODE-423452213 THIS AND THAT SOMETHING 1123123123123
CODE-72345we 1 RAND BLOB STUFF AND THAT AND SOMETHING ELSE4234234234234
I'd like to mark the lines which have the 1 after the initial CODE bit.
I tried:
But it doesn't work, probably because I am an idiot who doesn't know what I'm doing!
Would anyone be able to advise how I can achieve this?
Any advice much appreciated.
Thanks
Posted: Fri May 04, 2012 8:34 am
by ben_josephs
Select
Regular expression.
You don't need the
*, which indicates a sequence of any number (including zero) of occurrences of the preceding character. This will do it:
Search | Find... (
<F5>):
Find what: ^CODE-1
[X] Regular expression
Mark All
Posted: Fri May 04, 2012 9:02 am
by u20110427
Thanks for your reply.
That doesn't seem to work for me.
It doesn't find any thing from here:
Code: Select all
CODE-12345asd THIS AND THAT SOMETHING
CODE-12345sassasa 1 RAND BLOB STUFF AND THAT AND SOMETHING ELSE
CODE-423452213 THIS AND THAT SOMETHING 1123123123123
CODE-72345we 1 RAND BLOB STUFF AND THAT AND SOMETHING ELSE4234234234234
But as a quick test, it does find the last line here:
Code: Select all
CODE-12345asd THIS AND THAT SOMETHING
CODE-12345sassasa 1 RAND BLOB STUFF AND THAT AND SOMETHING ELSE
CODE-423452213 THIS AND THAT SOMETHING 1123123123123
CODE 1-72345we 1 RAND BLOB STUFF AND THAT AND SOMETHING ELSE4234234234234
Even though I have regular expression ticked in TextPad, it seems to be doing a literal find, e.g. finding only
CODE 1 rather than e.g.
CODE-12345sassasa 1
Thanks
Posted: Fri May 04, 2012 10:07 am
by ben_josephs
I don't understand. A literal search for the text ^CODE-1 would find the literal text ^CODE-1, with the ^ and the - in it. Neither a literal nor a regular expression search for ^CODE-1 or ^CODE-*1 (neither of which contains a space) would find the text CODE 1 (which does contain a space).
You are not telling us the whole story. Please clarify exactly what your text looks like and exactly what you are using to search it.
Posted: Fri May 04, 2012 10:36 am
by u20110427
I'm really sorry to waste your time. The file I have is at work and I didn't want to do a straight copy and paste as I didn't want to put work data on the web.
However, the test data was rubbish which I used. I am sorry about that.
Here is some better test data which correctly shows what I was trying to do. My previous version was useless, I now realise.
Code: Select all
TESTQ-ABCDE 123/ABC123235234
TESTQ-3gdfdf 1 Contract Costs
TESTQ-ABCDE Some Text Here
TESTQ-32234 1 Other Text There
TESTQ-dfg75 This Says Something
TESTQ-ABCDE This Says Something Else
TESTQ-FSDFdfg 1 My Test Data
TESTQ-fsdf33 Going From One To Another
TESTQ-fgsdf34 Friday May 4th
TESTQ-dsf4dfy 1 Testing One Two Three
TESTQ-235fgh45 Ability Agility House
I'd like to search for those lines where there is a 1 after the first block of text - i.e. those marked with a * below:
Code: Select all
TESTQ-ABCDE 123/ABC123235234
* TESTQ-3gdfdf 1 Contract Costs
TESTQ-ABCDE Some Text Here
* TESTQ-32234 1 Other Text There
TESTQ-dfg75 This Says Something
TESTQ-ABCDE This Says Something Else
* TESTQ-FSDFdfg 1 My Test Data
TESTQ-fsdf33 Going From One To Another
TESTQ-fgsdf34 Friday May 4th
* TESTQ-dsf4dfy 1 Testing One Two Three
TESTQ-235fgh45 Ability Agility House
I could see that the find of ^TESTQ will find lines starting with "TESTQ" but then do not know how to skip the variable length block of text after the dash, to then be able to find the "1".
I hope that's clearer, and sorry for my mistake.
Posted: Fri May 04, 2012 10:50 am
by ben_josephs
You haven't told us what is in the white space between the fields. This allows for sequences of spaces and/or tabs:
^TESTQ-[^ \t]+[ \t]+1[ \t]
Posted: Fri May 04, 2012 10:53 am
by u20110427
Thank you for your patience, that has worked.
Thanks for your help