2

I have field called name which has values like Ahmed and Marten. I need to check if this is the title without considering and.

The answer is no for if(name is title(name) ,'yes','no') because of and. So I need to get yes in the QGIS query.

2
  • Welcome to GIS Se. Sorry, your question is unclear. You want to delete and from Ahmed and Marten? You can do this using the replace() function.
    – Babel
    Commented Mar 19, 2023 at 21:53
  • 1
    Welcome to GIS SE. Please take a tour to learn how the site works. Commented Mar 19, 2023 at 22:09

2 Answers 2

5

You need to replace ' and' with ''. E.g. Ahmed and Marten -> Ahmed Marten, and then check replaced_name is title(replaced_name).

Use this expression:

with_variable(
    'text',  -- variable name
    replace("name", 'and ', ''), -- replace 'and ' with ''
    if ( @text is title(@text),  'yes', 'no' )
)

Ahmed and Marten -> yes
Ahmed and marten -> no
ahmed and Marten -> no
ahmed and marten -> no

0

I don't know if I understand your question correctly. But try something like:

if( strpos( 'the name you are searching for' , "name" ) > 0 , 'yes' , 'no' )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.