Hi Guys,
I have a file with lines starting from either 04 or 05, for lines starting with 04 I need to replace the 51 column value from N to Y.
Is it possible in Textpad?
Thanks
Manikanth
Replacing a column value in textpad
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Do you mean: for every line that begins with 04 and whose 51st character is N, you want that N changed to Y?
If so, try this:
Use "Posix" regular expression syntax:
If so, try this:
Use "Posix" regular expression syntax:
Search | Replace... (<F8>):Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
Find what: ^(04.{48})N
Replace with: \1Y
[X] Regular expression
Replace All
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
It isn't.
^(04.{48})N matches
where
.{48} matches
We replace the matched text with
^(04.{48})N matches
Code: Select all
^ the beginning of a line
( (start of captured text number 1)
04 the literal text "04"
.{48} any 48 characters (see below)
) (end of captured text number 1)
N the literal text "N"
.{48} matches
Code: Select all
. any character (other than newline)
{48} ... 48 times
Code: Select all
\1 captured text number 1
Y the literal text "Y"
Got It
Got It thank you very much..
its been six months i am trying to learn regular expression, but everytime i get confused with the brackets or square rounded 1's and literals..its a mess...can you suggest any easy understandble material and hands on on regular expression.
its been six months i am trying to learn regular expression, but everytime i get confused with the brackets or square rounded 1's and literals..its a mess...can you suggest any easy understandble material and hands on on regular expression.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
TextPad's help has some rather brief notes on regular expressions. Look under
Reference Information | Regular Expressions,
Reference Information | Replacement Expressions and
How to... | Find and Replace Text | Use Regular Expressions.
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.
A standard reference for regular expressions is
Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/
But be aware that the regular expression recogniser used by TextPad is very weak compared with modern tools. So you may get frustrated if you discover a handy trick that works elsewhere but doesn't work in TextPad.
Reference Information | Regular Expressions,
Reference Information | Replacement Expressions and
How to... | Find and Replace Text | Use Regular Expressions.
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.
A standard reference for regular expressions is
Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/
But be aware that the regular expression recogniser used by TextPad is very weak compared with modern tools. So you may get frustrated if you discover a handy trick that works elsewhere but doesn't work in TextPad.