I have looked around and found multiple ways to replace a letter for example: http://stackoverflow.com/questions/13469939/replacing-characters-in-string; however, I need to replace the third vowel (aeiou not y) in a word with its accented form (áéíóú). For example
Example > examplé
Fashion > fashión
Each word will have at least three vowels.
Find and accent a vowel
Moderator: DosItHelp
Re: Find and accent a vowel
It always depends on you codepage settings if non-ASCII characters work. You may try this
Steffen
Code: Select all
@echo off &setlocal EnableDelayedExpansion
for /f "tokens=2 delims=:" %%i in ('chcp') do set /a oemcp=%%~ni
for /f "tokens=3" %%i in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage" /v "ACP"') do set /a acp=%%i
>nul chcp %acp%
for %%i in ("a=á" "e=é" "i=í" "o=ó" "u=ú") do set %%i
>nul chcp %oemcp%
for %%i in (
example
fashion
) do (
set "word=%%~i"
set "word="!word:a=" "a" "!""
set "word=!word:e=" "e" "!"
set "word=!word:i=" "i" "!"
set "word=!word:o=" "o" "!"
set "word=!word:u=" "u" "!"
set "n=0"
set "newword="
for %%j in (!word!) do (
set /a "n+=1"
if !n!==6 (
set "newword=!newword!!%%~j!"
) else (
set "newword=!newword!%%~j"
)
)
echo !newword!
)
pause
Steffen
Re: Find and accent a vowel
Thanks aGerman, I cant wait to try it!