A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » General XP issues or comments
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

regexp syntax to make two search-&-replace into one search-&-replace please!



 
 
Thread Tools Display Modes
  #1  
Old September 9th 18, 03:26 AM posted to alt.comp.os.windows-10,alt.os.linux,microsoft.public.windowsxp.general
Doyun Jahng
external usenet poster
 
Posts: 5
Default regexp syntax to make two search-&-replace into one search-&-replace please!

May be you can help on gvim regexp syntax to get 1 command to work?
The problem is to convert 4 character in one regexp command!

This is four character convert which is what I want to do in 1 command!
convert open single quote d145 to straight single quote d39 (')
convert close single quote d146 to straight single quote d39 (')
convert open double quote d147 to straight double quote d34 (")
convert close double quote d148 to straight double quote d34 (")

The "digraph" percent sign (%) only work one at a time.
open single quote (d145) to straight single quote (d39) - :%s/\%d145/'/g
close single quote (d146) to straight single quote (d39) - :%s/\%d146/'/g
open double quote (d147) to straight double quote (d34) - :%s/\%d147/"/g
close double quote (d148) to straight double quote (d34) - :%s/\%d148/"/g
I can not get the syntax correct to do all 4 conversion at once!

The "\d" make the 4 command above to 2 command (nice!!!!!)
open/close single quote to straight single quote - :%s/[\d145,\d146]/'/g
open/close double quote to straight double quote - :%s/[\d147,\d148]/"/g

But I can not understand yet syntax to make above to 1 command!
May be you can help on gvim regexp syntax to get 1 command to work?
Ads
  #2  
Old September 9th 18, 03:03 PM posted to alt.comp.os.windows-10,alt.os.linux,microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 744
Default regexp syntax to make two search-&-replace into one search-&-replace please!

On Sun, 9 Sep 2018 11:26:10 +0900, Doyun Jahng wrote:
May be you can help on gvim regexp syntax to get 1 command to work?
The problem is to convert 4 character in one regexp command!

This is four character convert which is what I want to do in 1 command!
convert open single quote d145 to straight single quote d39 (')
convert close single quote d146 to straight single quote d39 (')
convert open double quote d147 to straight double quote d34 (")
convert close double quote d148 to straight double quote d34 (")

The "digraph" percent sign (%) only work one at a time.
open single quote (d145) to straight single quote (d39) - :%s/\%d145/'/g
close single quote (d146) to straight single quote (d39) - :%s/\%d146/'/g
open double quote (d147) to straight double quote (d34) - :%s/\%d147/"/g
close double quote (d148) to straight double quote (d34) - :%s/\%d148/"/g
I can not get the syntax correct to do all 4 conversion at once!

The "\d" make the 4 command above to 2 command (nice!!!!!)
open/close single quote to straight single quote - :%s/[\d145,\d146]/'/g
open/close double quote to straight double quote - :%s/[\d147,\d148]/"/g

But I can not understand yet syntax to make above to 1 command!
May be you can help on gvim regexp syntax to get 1 command to work?


I'm not sure gvim can actually do a conditional replacement using a single
regular expression. IME, only programming languages can do it.
  #3  
Old September 10th 18, 04:19 AM posted to alt.comp.os.windows-10,alt.os.linux,microsoft.public.windowsxp.general
朋友
external usenet poster
 
Posts: 1
Default regexp syntax to make two search-&-replace into one search-&-replace please!

Doyun Jahng wrote:

May be you can help on gvim regexp syntax to get 1 command to work?
The problem is to convert 4 character in one regexp command!

This is four character convert which is what I want to do in 1 command!
convert open single quote d145 to straight single quote d39 (')
convert close single quote d146 to straight single quote d39 (')
convert open double quote d147 to straight double quote d34 (")
convert close double quote d148 to straight double quote d34 (")

The "digraph" percent sign (%) only work one at a time.
open single quote (d145) to straight single quote (d39) - :%s/\%d145/'/g
close single quote (d146) to straight single quote (d39) - :%s/\%d146/'/g
open double quote (d147) to straight double quote (d34) - :%s/\%d147/"/g
close double quote (d148) to straight double quote (d34) - :%s/\%d148/"/g
I can not get the syntax correct to do all 4 conversion at once!

The "\d" make the 4 command above to 2 command (nice!!!!!)
open/close single quote to straight single quote - :%s/[\d145,\d146]/'/g
open/close double quote to straight double quote - :%s/[\d147,\d148]/"/g

But I can not understand yet syntax to make above to 1 command!
May be you can help on gvim regexp syntax to get 1 command to work?



This is a job for the Vim-script tr() function, not for regexp.

http://vimdoc.sourceforge.net/htmldoc/usr_41.html#string-functions
http://vimdoc.sourceforge.net/htmldoc/eval.html#tr()
https://stackoverflow.com/questions/25665318/vim-equivalent-of-the-tr-command

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 10:18 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 PCbanter.
The comments are property of their posters.