MS Word - how to replace numbers with themselves, but bold? Initiator des Themas: LEXpert
| LEXpert Vereinigte Staaten Local time: 04:39 Mitglied (2008) Kroatisch > Englisch + ...
In MS Word (Office 2007), I would like to search for all one- and two-digit numbers in a section of the text and replace the numbers with same numbers, but bolded. I can search for single digits (use wildcards, find: [1-9]), and this finds the numbers (finding just single digits will work Ok in this situation). However, I can't figure out what the Replace string should be. Applying a bold attribute to the replacement string is easy enough, but what is the actual replacement string? Replace: [1-9... See more In MS Word (Office 2007), I would like to search for all one- and two-digit numbers in a section of the text and replace the numbers with same numbers, but bolded. I can search for single digits (use wildcards, find: [1-9]), and this finds the numbers (finding just single digits will work Ok in this situation). However, I can't figure out what the Replace string should be. Applying a bold attribute to the replacement string is easy enough, but what is the actual replacement string? Replace: [1-9] will simply insert "[1-9]", so that's not it. Any ideas? TIA, Rudi ▲ Collapse | | | Ambrose Li Kanada Local time: 05:39 Englisch + ...
Regular expression syntax in all text editors should be roughly similar, so the answer probably involves some variation of possibly-backslash-escaped parentheses (the grouping operator), and \1 (backr... See more Regular expression syntax in all text editors should be roughly similar, so the answer probably involves some variation of possibly-backslash-escaped parentheses (the grouping operator), and \1 (backreferences). According to http://office.microsoft.com/en-us/word-help/find-and-replace-text-by-using-regular-expressions-advanced-HA102350661.aspx this should do the trick. (I don’t have Word to test whether this actually works or not.) Search string: (<[1-9][0-9]?>) This should match 1–9 optionally followed by 0–9, preceded by the beginning of a word boundary, and followed by a word boundary. The parentheses make it possble to reference the match in the replace string. Replace string: Just use \1 to represent whatever is matched.
[Edited at 2013-03-24 03:45 GMT] ▲ Collapse | | | wotswot Frankreich Local time: 11:39 Mitglied (2011) Französisch > Englisch Search for 1 and 2-digit numbers | Mar 24, 2013 |
The correct pattern-matching syntax in Word is: ([0-9]{1,2}) (in English-language editions of Word), or ([0-9]{1;2}) (in French-language editions of Word, which use the semi-colon instead of the comma between the curly brackets (enumerator clause)). (Term conventions: [] = square brackets, () = round brackets, {} = curly brackets) Incidentally, I always use [0-9] instead of [1-9] because French numbers under 10 (dates in particular) often include the leadin... See more The correct pattern-matching syntax in Word is: ([0-9]{1,2}) (in English-language editions of Word), or ([0-9]{1;2}) (in French-language editions of Word, which use the semi-colon instead of the comma between the curly brackets (enumerator clause)). (Term conventions: [] = square brackets, () = round brackets, {} = curly brackets) Incidentally, I always use [0-9] instead of [1-9] because French numbers under 10 (dates in particular) often include the leading 0 (zero). One "gotcha" I sometimes encounter: some people use the capital O (the letter between N and P!) instead of the 0 (zero)! Go figure! I should just point out that Word's pattern-matching (aka wildcard) syntax is not strictly speaking Regex (regular expression) syntax, merely a simplified (more user-friendly) subset thereof. In Replace, just enter \1 and set it to Bold. ▲ Collapse | | | LEXpert Vereinigte Staaten Local time: 04:39 Mitglied (2008) Kroatisch > Englisch + ... THEMENSTARTER @Wotswot - perfect, thanks! | Mar 24, 2013 |
Wotswot's solution worked perfectly. Thanks to you and Ambrose for your efforts. Much appreciated! | |
|
|
Ambrose Li Kanada Local time: 05:39 Englisch + ...
wotswot wrote: I should just point out that Word's pattern-matching (aka wildcard) syntax is not strictly speaking Regex (regular expression) syntax, merely a simplified (more user-friendly) subset thereof. Technically speaking, for a notation to be regex, all it has to support is *, ?, alternation, grouping, and some way to specify a set of characters to match. All other things can be derived from these and are merely notational conveniences. But of course, if we take such a basic definition of regex to go with then we don’t even have backreferences (which are vital for find-and-replace). So I guess it depends on what we mean by “regex.” PS: Sorry for the incessant edits.
[Edited at 2013-03-24 20:08 GMT] | | | Matches three-number digits too ... | Mar 25, 2013 |
([0-9]{1,2})
Matches 123, 456 and 789 too. | | | Ambrose Li Kanada Local time: 05:39 Englisch + ... word boundaries | Mar 25, 2013 |
trhanslator wrote: ([0-9]{1,2}) Matches 123, 456 and 789 too. That’s quite expected. That’s why you need the < and > to delimit the beginning-of- and end-of-word boundaries… | | | To report site rules violations or get help, contact a site moderator: You can also contact site staff by submitting a support request » MS Word - how to replace numbers with themselves, but bold? CafeTran Espresso | You've never met a CAT tool this clever!
Translate faster & easier, using a sophisticated CAT tool built by a translator / developer.
Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools.
Download and start using CafeTran Espresso -- for free
Buy now! » |
| TM-Town | Manage your TMs and Terms ... and boost your translation business
Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.
More info » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |