Skip to main content
Known Participant
November 10, 2019
Question

Find a word at the beginning of the line?

  • November 10, 2019
  • 2 replies
  • 1437 views

Hi all,

 

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

 

Best Regards

This topic has been closed for replies.

2 replies

Jongware
Community Expert
Community Expert
November 11, 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:

Known Participant
November 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.

platm72
Inspiring
November 11, 2019

Hi,

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

^yourWord

 

^ – means shift 6 

regards M.

Known Participant
November 11, 2019

Thank you platm72.

 

Your solution is correct for (Beginning of Paragraph).

 

The question is about (Beginning of a line).

 

Regards