Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 04-20-2018, 05:39 AM
Cosmo Cosmo is offline Regular expressions and field codes Windows Vista Regular expressions and field codes Office 2007
Competent Performer
Regular expressions and field codes
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Thanks for the response. I'm attaching a demo file with a function 'tetingRegEx'.

For the purposes of this test, I have simplified the regular expression to a simple text pattern, but the one I will be using is much more complicated. This doesn't affect the purpose of this test.

Running the function should highlight every instance of 'Lorem' within the document. There are 2 fields (a 'CreateDate' field, and a text form field) after the second paragraph. In the paragraphs after these fields, the text highlighted is not the found text.

I figured it was due to a discrepancy between the Field.code ( CREATEDATE \@ "M/d/yyyy" \* MERGEFORMAT ) vs Field.result (4/2/2018), but I don't see any correlation between those numbers. e.g. the date field code is 43 characters, the result is 8 characters. But it seems to offset the found range by 46 characters.

If I could find out how to calculate the offset (46 for the date) from each field, then I could loop through all fields that preceed the found text and adjust the position.
Attached Files
File Type: docm TestingRegex.docm (19.7 KB, 11 views)
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expressions and field codes regular expressions in footnotes loes Word 3 09-04-2019 07:52 AM
Word Regular Expressions: zero or more occurences? tinfanide Word 6 09-16-2015 03:13 PM
Regular expressions and field codes 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 and field codes Regular Expressions: [!0-9] does not work??? tinfanide Excel Programming 4 05-30-2012 04:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:33 AM.


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