Find one thing and Replace another

So I want to find white spaces in a text, but only in a certain environment. I have a list of Arabic words and their English translations next to them. What I want is to be able to replace the spaces in between the Arabic words with a Tab, but keep the spaces that are in between two English words as spaces.

I thought of using wildcards and typing the following in the Find box: [ا-ي][ ][a-z]

But if I replace that with a Tab character, or any character, it gets rid of the Arabic and English letters as well.

Is there a way to find those spaces, and only replace the space, and not the surrounding characters?

Here is a sample of the word list if you need it:

التّاريخ History

هَلَّق Now

مَبروك Congratulations!

اللّٰه يبارِك فيك Response to Congratulations

And the range of Arabic letters can be defined as [ا-ي]

Thanks very much!

If you search for

([ا-ي])( {1,})([a-z])

then you can replace with

\1^t\3

For more, see http://www.gmayor.com/replace_using_wildcards.htm.

Microsoft MVP (Word) since 1999
Fairhope, Alabama USA
http://ssbarnhill.com
http://wordfaqs.ssbarnhill.com
Screen shots captured with TechSmith's Snagit

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Hello

Presuming that you want to replace the space between the Arabic expression and its English rendering with a tab character, please note the following:
- the range of Arabic letters is [ء-ي] not [ا-ي].
- if some Arabic expressions end with a diacritic (7arakah), you should include the diacritics in the range. That would be [ء-ْ] (hamza to sukun)
- Since the English expression could start with a capital letter, the English range should be [a-zA-Z]

With "Use wildcards" checked, type in the "Find what" field the following:
([ء-ي]) ([a-zA-Z])
or, in case of possible ending diacritics:
([ء-ْ]) ([a-zA-Z])

In the "Replace with" field:
\1^t\2

Important note: When I copied your sample to a Word document, I noticed that what's actually between the Arabic expression and its English rendering is not a regular space. It's a nonbreaking space. (If this is the case in your Word document, then the above-mentioned solution won't work.) Go to your document and press CTRL+SHIFT+8. Do you see small circles between the Arabic and the English? (Press CTRL+SHIFT+8 again if you want them to disappear) If yes, and those circles are only found between the Arabic and the English, you can easily search ^s and replace it with ^t (with or without use of wildcards; works with both). If you need to apply the above-mentioned solution, replace the space with ^s

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Actually ^s is not necessary in searching for nonbreaking spaces, only for replacing with them. Searching for an ordinary space will also find nonbreaking spaces.

Your expression with a single space will work provided there is just one space; I was allowing for the possibility of there being more than one.

Microsoft MVP (Word) since 1999
Fairhope, Alabama USA
http://ssbarnhill.com
http://wordfaqs.ssbarnhill.com
Screen shots captured with TechSmith's Snagit

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I thought that searching for the ordinary space also finds nonbreaking spaces only in regular search, not with "Use wildcards". Probably it depends on the Office version?

{1,} is a good trick to find multiple occurrences. I've seen a lot of texts with more than one space between two words.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

You're right. I so seldom use wildcards that I hadn't realized that. Sorry!

As for the multiple spaces, although the sample the OP offers has only one space, the wording was ambiguous, so I was allowing for all possibilities.

Microsoft MVP (Word) since 1999
Fairhope, Alabama USA
http://ssbarnhill.com
http://wordfaqs.ssbarnhill.com
Screen shots captured with TechSmith's Snagit

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thank you Suzanne and barkoosh! Both of your options worked perfectly well (although there were a few words with () around them that complicated it a bit).

Also thank you barkoosh for telling me about the hamza and sukuun. I didn't realize diacritics would factor into that.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

(You can add the parenthesis to the range).

This is how you can tell the correct range to use in case of wildcards. (Go to Insert > Symbol > More symbols.) You can see in the picture (mine is Office 2010) that the range of Arabic letters actually starts with the hamza (the character after the Arabic question mark) and ends with yaa. If you starts the range with ا (alef), you would miss ء - آ - أ - ؤ - إ - ئ.

Notice that since the diacritics come straight after the Arabic letters in this chart of characters, you can include them in your range by typing [ء-ْ] (hamza to sukun; the sukun is the last diacritic on the list).

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 289 Applies to: