Copy link to clipboard
Copied
My .html file is filled with anchor tags after I export to HTML. <a id="_idTextAnchor006"></a>.
I'm trying to figure out how to use GREP to remove these. Here is my code:
Find what:
<a id="_idTextAnchor\d\d\d"></a>
Change to:
blank
Copy link to clipboard
Copied
I'm not sure this is even an InDesign question? Sounds like you're asking how to perform a GREP search using a text editor? If you don't want the anchors, why not delete them from the InDesign document prior to export?
Copy link to clipboard
Copied
I am using the built-in InDesign search and replace, not with a text editor. The .HTML file I was referencing is from an .indd export.
Copy link to clipboard
Copied
A text anchor is ~a
In InDesign Grep search
You would look for
(<a id="_id)~a(\d\d\d"></a>)
Change to
$1$2
Copy link to clipboard
Copied
If you want to delete all anchors in InDesign, just reolace ~a with nothing. To delete certain anchors in .html files, the code you posted should do the trick. Are you sure that your text editor supports GREP?
Copy link to clipboard
Copied
Thank you, this is the solution!
Copy link to clipboard
Copied
Which one? Deleting the anchors in InDesign or using your Grep replacement in the html files?
Copy link to clipboard
Copied
Sorry for the confusion. It actually seems like neither is working to remove the text anchors.
Here is the code I tried.
grep {findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}
grep {findWhat:"~a(\d\d\d"></a>)"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}
Copy link to clipboard
Copied
There's no point trying the second one because your document contains anchors as InDesign objects, not as text strings. That second one should be used on your html files (using any editor that supports grep).
The first one doesn't work, probably because of the option 'wholeWord', which is not compatible with Grep. Try removing that option and try again.
P.
Copy link to clipboard
Copied
Thank you for the help. I tried your suggestions with the code variants below. Neither work to remove the anchors.
```grep {findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.```
```text{findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.```
Copy link to clipboard
Copied
Sorry for the incorrect formatting. This forum seems to have some trouble with Chrome.
grep {findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.
text{findWhat:"~a"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true} remove anchor tags.
Copy link to clipboard
Copied
Also, is there a guide or any resources you can suggest for how to use find/replace with inDesign? There are so many nuances with inDesign's find/replace and GREP doesn't seem to function like regular regex.
Copy link to clipboard
Copied
Do you find anything when you search for ~a using the Find/Change window? Before trying to find it with a script, make sure that what you're after is in fact in your document.
> GREP doesn't seem to function like regular regex
Nowadays the notion 'regular regex' is a variable and fluid one. There are several dialects of regular expressions. For InDesign's grep, see https://creativepro.com/now-available-grep-in-indesign-3rd-edition/