Being unfamiliar with coding I'm having trouble tweaking the code below. I need to hyperlink the "#" and everything after the "#" until a "space". The digits after the "#" can be variables and there may be as many as five digits.
Sample below:
var doc = app.activeDocument;
// get URL
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = '(?i)(?<=# )(https?|www)\\S+\\>=';
var mURL = doc.findGrep();
// get Texte
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = '#';
var mSource = doc.findGrep();
for (var k = 0; k <mSource.length; k++){
var mHyperlinkDestination = doc.hyperlinkURLDestinations.add(mURL[k].contents);
var mHyperlinkTextSource = doc.hyperlinkTextSources.add(mSource[k]);
mHyperlink = doc.hyperlinks.add(mHyperlinkTextSource,mHyperlinkDestination);
mHyperlink.name =mURL[k].contents;
mHyperlink.visible=false;
}
//remove URL text
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = '(?i)(?<=# )(https?|www)\\S+\\>=';
app.changeGrepPreferences.changeTo = '';
doc.changeGrep();