MS Word - how to replace numbers with themselves, but bold? Thread poster: LEXpert
| LEXpert United States Local time: 12:10 Member (2008) Croatian to English + ...
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 | | |
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 France Local time: 19:10 Member (2011) French to English 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 United States Local time: 12:10 Member (2008) Croatian to English + ... TOPIC STARTER @Wotswot - perfect, thanks! | Mar 24, 2013 |
Wotswot's solution worked perfectly.
Thanks to you and Ambrose for your efforts. Much appreciated! | |
|
|
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. | | | 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? Protemos translation business management system | Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!
The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.
More info » |
| 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! » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |