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

Why does this regularity still match the second space?

Advocate ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

9989.png

I was trying to avoid starting with three consecutive spaces.
I stumbled upon this expression not working.
That is, I was trying to avoid the “what” line.

Is my regularity wrong?

TOPICS
Bug , Feature request , How to , Import and export , Scripting

Views

152

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

It works fine for me

 

Don't know why it's so complicated - you could search for a single space (inserted by space bar) and it finds the same thing.

 

Can you elaborate or provide a larger sample set?

 

 

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

@dublove

 

What exactly are you trying to achieve? 

 

Remove those spaces? All of them or some? 

 

Replace them with something else? 

 

Remove whole 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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

To avvoid lines that start with three spaces, look for

^[^\h][^\h][^\h]

 

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 ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

^\S{3}

 

(^/)  The Jedi

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
Advocate ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

@Peter Kahrel 

I would like to use a forward and reverse check(? = or ? <!) to realize it。

 

Well, a different example might make more sense.
I'm trying to find and replace a space.
Except for spaces after numbers, except for consecutive spaces at the beginning of a paragraph.

I just realized that I can't replace spaces in (? <! [\d])(\h) expression, then add the condition.
(? <! [\d\h])(\h).

That is to say: (? <! [\h])(\h) may be meaningless.

690.png

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

@dublove

 

If you add "^" at the beginning of your GREP expression - it will find only paragraphs starting with your search phrase - as per examples from @Peter Kahrel and @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
Guide ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

You write:

 

"I'm trying to find and replace a space."

 

What space in your sample?

 

Apparently, you want to find a space not preceded by a number or another space, the "3 spaces" case being not taken in account. Right?

 

(^/)

 

Between, "(?<![\d\h])" won't never work because it's a Grep incorrect syntax.

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
Advocate ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

LATEST

Theoretically there is no problem.
In practice:(? <! \h)([a-z]) is established
But (? <! \h)(\h) does not hold.

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