adriank / ObjectPath

The agile query language for semi-structured data
http://objectpath.org
MIT License
380 stars 93 forks source link

Matching a string that includes single quote. #99

Closed nastasi closed 4 years ago

nastasi commented 4 years ago

I'm wondering how to escaping single quote in a simple comparison like:

  <string_attribute> is '<a string including single quote>'

Update, I found a Baroque way:

  <string_attribute> is 'name with single ' + "'" + ' quote' 
  # escaping with: quote, plus, double quotes, quote, double quotes, plus, quote

and the Rococo one:

  <string_attribute> is 'name with single ' + unescape('&apos;') + ' quote' 

Is it the most compact way to achieve it ?

adriank commented 4 years ago

Use Escape character.

On Sat, 23 May 2020 at 10:28 Matteo Nastasi notifications@github.com wrote:

I'm wondering how to escaping single quote in a simple comparison like:

is '' — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or unsubscribe . -- Greetings, Adrian Kalbarczyk

https://kalbarczyk.co | https://devyard.io

nastasi commented 4 years ago

@adriank

Use Escape character.

That is what I'm looking for from the beginning (also in the documentation), could you share which is it ?

adriank commented 4 years ago

https://github.com/adriank/ObjectPath/blob/master/tests/test_ObjectPath.py

There are examples.

On Sat, 23 May 2020 at 12:35 Matteo Nastasi notifications@github.com wrote:

Use Escape character.

That is what I'm looking for from the beginning (also in the documentation), could you share which is it ?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/adriank/ObjectPath/issues/99#issuecomment-633023466, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLE4SAARU7FPD2XYEMJMDRS6RGFANCNFSM4NILJLHQ .

-- Greetings, Adrian Kalbarczyk

https://kalbarczyk.co | https://devyard.io

nastasi commented 4 years ago

https://github.com/adriank/ObjectPath/blob/master/tests/test_ObjectPath.py There are examples.

I already looked that without any clue, I cannot find the escape character that you mention above. So, probably, the ...' + "'" + '... is the more compact way to escape quote in a delimited quote string, could you confirm ?

adriank commented 4 years ago

self.assertEqual(execute("'a'+'b'+\"c\""), 'abc')

On Sat, 23 May 2020 at 17:24 Matteo Nastasi notifications@github.com wrote:

https://github.com/adriank/ObjectPath/blob/master/tests/test_ObjectPath.py There are examples. I already looked that without any clue, I cannot find the escape character that you mention above. So, probably, the ...' + "'" + '... is the more compact way to escape quote in a delimited quote string, could you confirm ?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/adriank/ObjectPath/issues/99#issuecomment-633075517, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLE4VA7PLR5QZTRPXHUYDRS7TC7ANCNFSM4NILJLHQ .

-- Greetings, Adrian Kalbarczyk

https://kalbarczyk.co | https://devyard.io

nastasi commented 4 years ago

self.assertEqual(execute("'a'+'b'+\"c\""), 'abc')

I think you miss the point, I'm interested to compare with is the string a'b"c, not abc. What is the compactest way to do it ?

nastasi commented 4 years ago

The question seems to me clear from the beginning ... I'm sorry if it wasn't for you.