Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Find a word at the beginning of the line?

Explorer ,
Nov 10, 2019 Nov 10, 2019

Hi all,

 

Is it possibe to find a word, ONLY if it is at the beginning of the line?

 

Best Regards

TOPICS
How to , Type
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 10, 2019 Nov 10, 2019

Hi,

open find window (command/control F), select GREP tab and type:

^yourWord

 

^ – means shift 6 

regards M.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 10, 2019 Nov 10, 2019

Thank you platm72.

 

Your solution is correct for (Beginning of Paragraph).

 

The question is about (Beginning of a line).

 

Regards

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2019 Nov 10, 2019

Not in the user interface itself. The only GREP codes for "beginning of ..." are \A for Beginning of Story and "^" for Beginning of Paragraph and "\<" for Beginning of Word – see also the Online Help at https://helpx.adobe.com/indesign/using/find-change.html#metacharacters_for_searching (actually that list is far from complete as "Beginning of Story" is missing; but there is no hidden "Beginning of Line" code).

It can be scripted, but for a script tailored for your needs we need more information. This quick short one, for example, will search only the first occurrence of a word from the start of a selected story, and I am pretty sure you want more than that.

 

findText = prompt ("Find", "");
if (findText)
{
	app.findGrepPreferences.findWhat = '\\<'+findText+'\\>';
	list = app.selection[0].parentStory.findGrep ();
	while (list.length)
	{
		item = list.shift();
		if (item.characters[0] == item.lines[0].characters[0])
		{
			item.select();
			exit();
		}
	}
	alert ("Not found");
}

 as it will only find the first occurrence of the input word/words at the beginning of a line:

Screen Shot 2019-11-11 at 2.23.59 AM.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 26, 2019 Nov 26, 2019

Thank you Jongware very much for your details, which showed me that this feature does not exist in InDesign itself.

 

Your (pretty sure) is (pretty correct). I am looking for a similar of (Find/Change) feature.

 

Best Regards.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2023 Apr 24, 2023

Dear Jongware,
I just saw your answer to the "Find a word at the beginning of the line?" problem.
I have the same problem - in Tibetan, the character ། can never be at the beginning of a line (it is kind of comma, period or semicolon) - Tibetan uses hardly any spaces and never one before that character, so non-breaking spaces are not an option.
I tried your script, but could not get it to work (at all somehow). Is there a way to make it generally work to find all instances of a character at the beginning of any line?
Thank you, with kind regards S.J.G.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2023 Apr 24, 2023

I can't test this, since I don't have a Tibetan font, but you could try a GREP style that applies a No Break Character Style to   .།

This should force the ། character to stay with whatever character comes before it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2023 Jul 17, 2023
LATEST

(a some what quite late) Thank you very much. That works very well. (Have to type the Tibetan into the GREP style creation box, just marking and creating a new GREP style does not quite work with Tibetan.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines