Viewing 1 post (of 1 total)
  • Author
    Posts
  • #7771
    WmMitchell
    Participant

    Iโ€™m not very good at regex, but Iโ€™ve managed to get some code going that more or less works, at least, most of the time. But Iโ€™m wondering why some parts search and replace without any manual intervention, and other text isnโ€™t and it stops and I must press a key to initiate the S&R.

    Hereโ€™s part of the code in question. All of it has the same structure, so Iโ€™m at a loss โ€ฆ All the extra, clunky keystrokes I had to put it to get it to work but Iโ€™m sure there must be a more efficient means of continuous, automated S&R throughout an entire document (?):

    โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”
    document.selection.StartOfDocument(false);
    shell.SendKeys(โ€œ{CTRL DOWN}{CTRL UP}โ€);

    document.selection.Replace(โ€œ. โ€œ,โ€. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ. โ€œ,โ€. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ. โ€œ,โ€. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ. โ€œ,โ€. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ. โ€œ,โ€. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ? โ€œ,โ€? โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ? โ€œ,โ€? โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ! โ€œ,โ€! โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ! โ€œ,โ€! โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ: โ€œ,โ€: โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œ: โ€œ,โ€: โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œDr. โ€œ,โ€Dr. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œMr. โ€œ,โ€Mr. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œMrs. โ€œ,โ€Mrs. โ€œ,eeFindNext | eeReplaceAll);
    document.selection.Replace(โ€œLt. โ€œ,โ€Lt. โ€œ,eeFindNext | eeReplaceAll);

    document.selection.StartOfDocument(false);
    shell.SendKeys(โ€œ{CTRL DOWN}{CTRL UP}โ€);
    document.selection.Replace(โ€œ1/4โ€ณ,โ€ยผโ€,eeFindNext | eeReplaceAll);
    document.selection.StartOfDocument(false);
    shell.SendKeys(โ€œ{CTRL DOWN}{CTRL UP}โ€);
    document.selection.Replace(โ€œ1/2โ€ณ,โ€ยฝโ€,eeFindNext | eeReplaceAll);
    document.selection.StartOfDocument(false);
    shell.SendKeys(โ€œ{CTRL DOWN}{CTRL UP}โ€);
    document.selection.Replace(โ€œ3/4โ€ณ,โ€ยพโ€,eeFindNext | eeReplaceAll);
    โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

    Thanks!

Viewing 1 post (of 1 total)
  • The forum โ€˜Regular Expressionsโ€™ is closed to new topics and replies.