Specific character in specific position

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
gcotterl
Posts: 255
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Specific character in specific position

Post by gcotterl »

How do I find rows containing an 'x' in position 53?
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Click on Search/Find
Search for: ^.{52}x
Click on Mark All

Be sure to have check in Regular Expressions and POSIX is on.

Note, would like to let you know that there is now a separate Forum for Regular Expressions. That is where this type of question should be posted in the future.
Last edited by Bob Hansen on Thu May 04, 2006 10:46 pm, edited 1 time in total.
Hope this was helpful.............good luck,
Bob
hillsc
Posts: 35
Joined: Thu Jun 19, 2003 2:00 pm

Post by hillsc »

True, but if someone doesn't know the solution to their problem involves the use of regex's, what would make them think to post there?
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Got me! :oops:

But that person will probably know to do that now.....
Hope this was helpful.............good luck,
Bob
ACRobin
Posts: 134
Joined: Fri Nov 04, 2005 9:51 pm
Location: Northumberland,UK
Contact:

another method

Post by ACRobin »

Just for information and giving an alternative method:

If you put TP in "Block" mode
go to column 52 on the first row
Select one character (Shift + right arrow)
Select the whole column (Shift + CTRL + End)
Bring up the "Find" dialogue box
Type in "x" and you will notice that is says it search "Selected Text Only"

I tend to select "Book Mark lines" in the Find dialogue which allows later to "Copy Booked Marked Lines" if I am producing an extract file.

I must get a REGEX book, but at the moment as I have used the editor for such a long time, I can get by.
gcotterl
Posts: 255
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Special character in specific position

Post by gcotterl »

In the "Search for" box, ^.{52}x will find rows containing an 'x' in position 53:

How do I find rows containing a special character -- like a period or a comma -- in position 53?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

There's nothing special about a comma in regular expression search and replace. To search for a full stop when using regular expressions either escape it: \. or put it in a character class: [.]. So:
^.{52}\.
or
^.{52}[.]
.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Replace the x with the character you are looking for.

You may need to use "\" for some special RegEx characters. See the Help section on Regular Expressions.
Hope this was helpful.............good luck,
Bob
gcotterl
Posts: 255
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Special character in specific position

Post by gcotterl »

I originally tried

^.{52}.

but it bookmarked EVERY row.



Per your suggestion, I tried

^.{52}\.

and it bookmarked only the rows with a period in position 53.

Thanks.
bveldkamp

Post by bveldkamp »

Yeah, a single . means "any character" whereas \. means a literal .
Post Reply