Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search/replace special chars?

Tags:

replace

vim

After a copy-paste from Wikipedia into Vim, I get this:

  1 A   2    3 [+] Métier agricole<200e> – 44 P • 2 C   4 [×] Métier de l'ameublement<200e> – 10 P   5 [×] Métier de l'animation<200e> – 5 P   6 [+] Métier en rapport avec l'art<200e> – 11 P • 4 C   7 [×] Métier en rapport avec l'automobile<200e> – 10 P   8 [×] Métier de l'aéronautique<200e> – 15 P 

The problem is that <200e> is only a char.

I'd like to know how to put it in a search/replace (via the / or :).

like image 948
Olivier Pons Avatar asked Dec 09 '11 15:12

Olivier Pons


People also ask

How do you find and replace specific character or word?

Note: Select the arrow at the bottom of the Find and Replace dialog box to show all options. On the Special menu, select the special character that you want to find. Select in the Replace with box. On the Special menu, select the special character that you want to use as a replacement.

How do you replace special characters in regex?

If you are having a string with special characters and want's to remove/replace them then you can use regex for that. Use this code: Regex. Replace(your String, @"[^0-9a-zA-Z]+", "")

How do you remove special characters in Word?

Alternatively, you can press Ctrl+H. Click in the “Find What” box and then delete any existing text or characters. Click the “More>>” button to open up the additional options, click the “Special” button, and then click the “Paragraph Mark” option from the dropdown list.


1 Answers

Check the help for \%u:

                                 /\%d /\%x /\%o /\%u /\%U E678  \%d123  Matches the character specified with a decimal number.  Must be         followed by a non-digit. \%o40   Matches the character specified with an octal number up to 0377.         Numbers below 040 must be followed by a non-octal digit or a non-digit. \%x2a   Matches the character specified with up to two hexadecimal characters. \%u20AC Matches the character specified with up to four hexadecimal         characters. \%U1234abcd     Matches the character specified with up to eight hexadecimal         characters. 

These are sequences you can use. Looks like you have two bytes, so \%u200e should match it. Anyway, it's pretty strange. 20 in UTF-8 / ASCII is the space character, and 0e is ^N. Check your encoding settings.

like image 122
sidyll Avatar answered Oct 06 '22 17:10

sidyll