Hi there,I want to clean telefone numbers in vcard. Atm the nummbers look like this 123-54-789-00 and I want them to look like this 12345678900.
So I want to delete the "-" only in lines that include the string "TEL;TYPE=". But a full line looks like this: TEL;TYPE=WORK:123-54-789-00
So the operation has to look for the string with the TEL but ignore anything behind the "=".
I can't simply remove all "-" because some are in email adresses or streetnames.
Is there a way to do this?
Thx 4 F1
Well, I think we can achieve it with two consecutive Search/Replacements !
We'll need an extra character which DOESN'T exist in your file. Let suppose it's the # character ( You may choose the @, _ or ; character, as well. However, try to avoid characters that have special meaning in regexes, like, for example, ? or [. !
For each S/R :
Move back, if necessary, to the beginning of your file ( CTRL + Org )
Open the Replace dialog ( CTRL + H )
Fill in the two zones Find what: and Replace with : with the strings below
Select the Regular expression search mode
DON'T check any other square box option
Click on the Replace All button, at the right side
A) First regex :
SEARCH : .*TEL;TYPE=.*
REPLACE : $0#
B) Second regex :
SEARCH : -(?=.*#)|#
REPLACE : Nothing
=> So, the adding # character is used to mark all lines with a phone number :-)
In this first S/R, the form .* represents any string, even a zero length string, before and after the string TEL;TYPE=
In the second S/R, we're searching for a dash ( - ) ONLY IF it's followed further, on the same line, with the # character OR the # character. And we just replace it by Nothing, as it must be deleted
In this second S/R, the form (?=.*#) is called a lookahead, which must be verified, but which is NOT part of the final regex, the dash ( - ) to match.
In the second S/R, after the last dash, of each line, is deleted, the # character is matched by the second part of the alternative and is ALSO deleted !
You will find good documentation, about the new PERL Common Regular Expressions (PCRE), used by N++, since the 6.0 version, at the TWO addresses below :
The FIRST link concerns the syntax of regular expressions in SEARCH
The SECOND link concerns the syntax of regular expressions in REPLACEMENT
Oh, BTW, I do like your shortcut : Thx 4 F1 for Thanks for (your) help !!!
@ THEVENOT Guy:
It totally worked. You knew that, right? ;)
Awesome. Thank you very much.
Concerning the shortcut: I'm using it for at least 10 years now. Nobody ever paid attention. I have never ever seen it anywhere else. Feel free to use it. I'm happy you like it :)
Thx 4 F1!!! ;) :D