🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
2 messages
2 total messages Started by Schedule_Boy Wed, 04 Feb 2009 05:30
using grep to find one match per line
#1692
Author: Schedule_Boy
Date: Wed, 04 Feb 2009 05:30
14 lines
920 bytes
Hi,

How do you get grep to return a single line even when multiple matches are found on the same line?

I tried the (?-m) and (?-s) without success.

eg. searching for the string "sin" in the following line should return only one result not 2.

SG SIN Singapore

I don't want the search to stop after a single match, it should continue on successive lines

Thanks,
SB
Re: using grep to find one match per line
#1696
Author: Peter Kahrel
Date: Wed, 04 Feb 2009 10:05
5 lines
1105 bytes
GREP is case-sensitive, so "sin" doesn't find anything in "SG SIN Singapore". To search case-sensitively and whole words only, use (?i)\bsin\b

But your question isn't entirely clear. You start by asking "How do you get grep to return a single line even when multiple matches are found on the same line?", then you say "I don't want the search to stop after a single match, it should continue on successive lines". These two seem to contradich each other. Do you mean you want one match per line?

Peter
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads