Skip to main content
stray backtick
Source Link
ilkkachu
  • 147.8k
  • 16
  • 268
  • 441

The use case is rather simple. I have a text file, say the following named eg.txt:

'simple_example': 345, 'to_demonstrate': 232,
'regex': 'is not easy to use'

I am trying to capture the keys:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt`txt

It gives me error:

-bash: syntax error near unexpected token `('

Escaping the single quote does not help either:

grep -oP (?<=\')[a-zA-Z_0-9]+(?=\':) eg.txt

Nor does using extended grep help:

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

What is happening here? I am using linux bash with Windows 10 WSL.

The use case is rather simple. I have a text file, say the following named eg.txt:

'simple_example': 345, 'to_demonstrate': 232,
'regex': 'is not easy to use'

I am trying to capture the keys:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt`

It gives me error:

-bash: syntax error near unexpected token `('

Escaping the single quote does not help either:

grep -oP (?<=\')[a-zA-Z_0-9]+(?=\':) eg.txt

Nor does using extended grep help:

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

What is happening here? I am using linux bash with Windows 10 WSL.

The use case is rather simple. I have a text file, say the following named eg.txt:

'simple_example': 345, 'to_demonstrate': 232,
'regex': 'is not easy to use'

I am trying to capture the keys:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

It gives me error:

-bash: syntax error near unexpected token `('

Escaping the single quote does not help either:

grep -oP (?<=\')[a-zA-Z_0-9]+(?=\':) eg.txt

Nor does using extended grep help:

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

What is happening here? I am using linux bash with Windows 10 WSL.

Fix markup
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

The use case is rather simple. I have a text file, say the following named eg.txt:

'simple_example': 345, 'to_demonstrate': 232,
'regex': 'is not easy to use'

I am trying to capture the keys:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt`

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt It It gives me error:

-bash: syntax error near unexpected token `('

Escaping the single quote does not help either:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

grep -oP (?<=\')[a-zA-Z_0-9]+(?=\':) eg.txt

Nor does using extended grep help:

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

What is happening here? I am using linux bash with Windows 10 WSL.

The use case is rather simple. I have a text file, say the following named eg.txt:

'simple_example': 345, 'to_demonstrate': 232,
'regex': 'is not easy to use'

I am trying to capture the keys:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt It gives me error:

-bash: syntax error near unexpected token `('

Escaping the single quote does not help either:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

Nor does using extended grep help:

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

What is happening here? I am using linux bash with Windows 10 WSL.

The use case is rather simple. I have a text file, say the following named eg.txt:

'simple_example': 345, 'to_demonstrate': 232,
'regex': 'is not easy to use'

I am trying to capture the keys:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt`

It gives me error:

-bash: syntax error near unexpected token `('

Escaping the single quote does not help either:

grep -oP (?<=\')[a-zA-Z_0-9]+(?=\':) eg.txt

Nor does using extended grep help:

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

What is happening here? I am using linux bash with Windows 10 WSL.

Source Link

-bash: syntax error near unexpected token `(' when using lookahead and lookback?

The use case is rather simple. I have a text file, say the following named eg.txt:

'simple_example': 345, 'to_demonstrate': 232,
'regex': 'is not easy to use'

I am trying to capture the keys:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt It gives me error:

-bash: syntax error near unexpected token `('

Escaping the single quote does not help either:

grep -oP (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

Nor does using extended grep help:

grep -oE (?<=')[a-zA-Z_0-9]+(?=':) eg.txt

What is happening here? I am using linux bash with Windows 10 WSL.