I am attempting to find all complete words which contain an asterisk at the beginning and the end - for instance, "*Hello?" or "*you".
From what I've read, I would have thought that the following expression would do that just fine:
\<\*.*\*\>
\< denoting the beginning of a word.
\* escaping the first asterisk
.* acting as a placeholder for any number of characters
\* escaping the second asterisk
and finally
\> to denote the end of the word.
Yet, the string doesn't do a thing. Why might that be? If it matters, I'm using this string in InDesign, but I figured here would be a better place to ask since it's technically a scripting issue. Might InDesign be using a pseudo-GREP structure, or is my script just wrong?
from what i know when were dealing with asterisk(*) char in a line we need to use double qoutes. This evaluates the "middle " (.) and use escape character on both the first character (^) and last character ($).
-bash-3.2$ cat test
*ryan*
*you
*me*
-bash-3.2$ cat test | grep "^\*.*\*$"
*ryan*
*me*
-bash-3.2$
\<\*.*\> , however, doesn't return words that start with an asterisk. I think it's choking on asterisks for some reason. It doesn't make a difference if instead of escaping the asterisk, I put it in single or double quotes, like so:
\<'*'.*\>
\<"*".*\>
Can an asterisk not be legitimately part of a "word" - as defined by GREP? I figured a word was simply any string with spaces or tabs around it.
Simply that - your sample code does not return any results.
InDesign seems to store paragraphs as strings - as such I want to find words within that string that begin and end with an asterisk. For that, I believe the proper syntax is \< and \>
Thinking perhaps the problem might be with the "word" syntax (\< and \>), I tried simply checking for a space, an asterisk, any string, another asterisk, and another space: