Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2013, 12:03 AM
Kreol2013 Kreol2013 is offline Regular expressions for text with complex formatting Windows 7 32bit Regular expressions for text with complex formatting Office 2013
Novice
Regular expressions for text with complex formatting
 
Join Date: Apr 2013
Posts: 8
Kreol2013 is on a distinguished road
Question Regular expressions for text with complex formatting

Greetings Dear forum.
I apologize for my English
I have a rich text.
Template text is: Sanskrit12 | Clarendon Indelodzhik | Charter Capital
I am using VBA spending, change the characters with this option format and have the desired result with formatting.
But when I want to use a regular expression, I take this option and the regular expression captures respectively typeface.
Example: obrabotatsya should only 1st word not capturing anything extra (g े r.)
अकृत्वा akṛtvā g r. (Āhāram) not accepting (food)



But I do not need this, I need to use a regular expression to one font, but if I search text Sanrit12 and I replace the letter A then it automatically becomes a font Mangol and use a regular expression search Sanskrit 12 font is not suitable.
And I have no idea what to do.
Structuring the attachment has the form, but there are documents that are similar to porridge.
Thought:
Possible solution is to use styles for fonts, but how to do it correctly, I do not understand.
That is, if I highlight text in Sanskrit 12 font style 1 and Tim New Roman style in two regular season and will look for the Latin letter "a" is when the only style I find that letter in Sanskrit 12.
The document was written on large macro coloring text.
Written for typos. So that you can immediately see the error with applications fonts.
Written intuitively likely grammatical wrong. If you can not be a problem, please look it up.
Do not laugh out loud, kicking strongly not to beat

Same change of character by character created specifically for converting font Sanskrit12 in Santipur OT. processed in C # but in terms of standard features search / replace a Word

Formed as an intermediate output 2 text document in the 1st replaced the Sanskrit 12 got a string of examples (dirty tekt).
And the second one with the original text (in kotoros Sanskrit12).
need to change the text in the document 2 to 12 Sanskrit text that was created in one document
example:

Document1 अंशु aṅç ु m part, share, edge, end, ray, light.
Document2 A <zu aṅçu m part, share, edge, end, ray, light.

Require replacement of the 1st word in this situation.

I hope I was able to dnesti all thought.
I would be very grateful for your help.
I will try to answer all the questions.
Best regards, Anton
Attached Files
File Type: doc Forum.doc (71.5 KB, 11 views)
Reply With Quote
  #2  
Old 04-12-2013, 07:33 PM
macropod's Avatar
macropod macropod is offline Regular expressions for text with complex formatting Windows 7 64bit Regular expressions for text with complex formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code has many inconsistencies in the way you have used the variables for the bold and italics. You should fix those.

Your 'Replase_New' sub could be simplified:
Code:
Sub Replase_New(FFText As String, FFName As String, FFBold As String, FFItalic As String, _
    RFFText As String, RFFName As String, RFFColor As WdColor, RFFBold As String, RFFItalic As String, _
    bFormat As Boolean, bCase As Boolean, bWholeWord As Boolean, bWildcards As Boolean)
    With ActiveDocument.Range.Find
        .ClearFormatting
        .Text = FFText
        With .Font
          If FFBold = "True" Then .Bold = True
          If FFBold = "False" Then .Bold = False
          If FFItalic = "True" Then .Italic = True
          If FFItalic = "False" Then .Italic = False
        End With
        With .Replacement
            .ClearFormatting
            .Text = RFFText
            With .Font
                .Color = RFFColor
                .Name = RFFName
                If RFFBold = "True" Then .Bold = True
                If RFFBold = "False" Then .Bold = False
                If RFFItalic = "True" Then .Italic = True
                If RFFItalic = "False" Then .Italic = False
            End With
        End With
        .Forward = True
        .Wrap = wdFindContinue
        .Format = bFormat
        .MatchCase = bCase
        .MatchWholeWord = bWholeWord
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = bWildcards
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Also, whenever you're using wildcards, you should specify both a Find string and (unless you want to delete the found text) a Replace string. For example:
Code:
Call Replase_New("*", "Cambria", "True", "True", "^&", "Clarendon Indologique", wdColorGreen, "True", "True", True, False, False, True)
You'll see that I've inserted '*' and '^&' for the Find and Replace expressions. Also, where you don't care about whether the Find and Replace strings are bold or italic, you can simply leave both empty or use something like "Null". That way, instead of having three lines for 'Call Replase_New(FinderArray_abr(count)' you could have one:
Code:
Call Replase_New(FinderArray_abr(count), "", "Null", "Null", ReplaseArray_abr(count), "Charter Capital", wdColorBlue, "False", "False", True, True, False, False)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
find/replace, formatting, regex



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expressions for text with complex formatting Regular Expressions: match words within quotes? tinfanide Word VBA 3 02-02-2013 10:07 PM
regular expressions for empty lines eNGiNe Word 1 01-21-2013 06:38 AM
Regular expressions for text with complex formatting Regular expressions: lower case after hyphen SusanG Word 2 06-06-2012 11:58 PM
Regular expressions for text with complex formatting Regular Expressions: [!0-9] does not work??? tinfanide Excel Programming 4 05-30-2012 04:09 AM
Issue skipping characters by Regular Expressions in Word pochtara Word VBA 0 04-01-2010 05:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft