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

Find character in middle of paragraph, but not at beginning

Explorer ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

Hi!

I'm trying to to figure out how to change the location "Beginning of paragraph" to do the opposite. I need to find en-dashes that are not at the beginning of a paragraph. I've tried ^[^]-|– but its not working as I was hoping.

Rune

Views

545

Translate

Translate

Report

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

correct answers 1 Correct answer

Guide , Apr 13, 2018 Apr 13, 2018

Hi,

\V\K(-|–)

Best,

Michel, from FRIdNGE

Votes

Translate

Translate
Community Expert ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

I would search for word characters, could be comma or other dots, followed by space and then the dash. I do it always for corrections to the German dash (n-dash, Gedankenstrich, is not allowed at the beginning of a line.)

Votes

Translate

Translate

Report

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 ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

Thanks for your suggestion.

I did try to search for "any word character->any white space->en-dash|hyphen" but for some strange reason that search also included en-dashes at the beginning of paragraph. I think it is because it includes the last character of the previous paragraph??

Rune

Votes

Translate

Translate

Report

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
Guide ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

Hi,

\V\K(-|–)

Best,

Michel, from FRIdNGE

Votes

Translate

Translate

Report

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 ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

Thanks!

This worked!

Rune

Votes

Translate

Translate

Report

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
Guide ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

You doubted!? …

Best,

Michel

Votes

Translate

Translate

Report

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 ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

Hehe - not at all:)

Can I ask you what \V and \K is searching for?

Votes

Translate

Translate

Report

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
Guide ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

\K is a lookbehind, \V is not a vertical space [especially including a carriage-return].

So, the regex searches all en-dash preceded by something that is not a … carriage-return!

That means that it can't find an en-dash at the beginning of a para because the previous glyph will be …

[ I let you answer to see if you have understood! -- I know this kind of regex is really loony!  ]

Best,

Michel

Votes

Translate

Translate

Report

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 ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

Ok, it makes totally sense. Thanks again.

Rune

Votes

Translate

Translate

Report

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
Guide ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

LATEST

Some could tell this other Grep code is better because clearer:

(?<!\v)(-|–)

Explanation: an en-dash that is not preceded by … a carriage-return!

… But it's not true [more greedy!]! 

As you see, Grep is truly simple to play!

Have a good day!

Best,

Michel

Votes

Translate

Translate

Report

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