locked
Select one or severals words of a regular expression RRS feed

  • Question

  • User-458598543 posted

    Hello,

    I'm using visual studio 2015 and MySql.

    I want to set a select query which selects one or several words of an regular expression.

    Fo exemple :

    Set TextBox TB_RequeteLike : "Recherche Vaisselle en terre".

    Field of Datatable : TP_Annonce = 'Vaisselle en terre'.

    Match : Vaisselle en terre

    Code c# :

    SqlDataSource1.SelectParameters.Clear();
                DataSourceSelectArguments args = new DataSourceSelectArguments();
                SqlDataSource1.SelectCommand = "SELECT T_JP_Annonce_Titre FROM t_jp_annonce WHERE T_JP_Annonce_Titre REGEXP '(^/?Titre/^$)' LIMIT 1 ";      // Tryng
                SqlDataSource1.SelectParameters.Add("?Titre", TB_RequeteLike.Text);

    Thanks for your help !

    Tuesday, June 27, 2017 1:18 PM

Answers

  • User269602965 posted

    SELECT T_JP_Annonce_Titre FROM t_jp_annonce WHERE T_JP_Annonce_Titre LIKE '%Titre%' LIMIT 1

    In SQL the WHERE X LIKE wildcard expression actually generates REGEXP behind your code.

    Also depending on your database, for example Oracle, some database support various REGEXP functions for more complex matching than simple "wildcard" filtering.

    Oracle has REGEXP_LIKE, REGEXP_INSTR, REGEXP_SUBSTR among others.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 22, 2017 2:32 PM
  • User-458598543 posted

    Hello,

    Thanks for your answer, the queries systems that your purpose are interessants but after research, I use the old reactually (updated) method "Match ... Against ...".

    Bye !

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 31, 2017 12:15 PM

All replies

  • User269602965 posted

    SELECT T_JP_Annonce_Titre FROM t_jp_annonce WHERE T_JP_Annonce_Titre LIKE '%Titre%' LIMIT 1

    In SQL the WHERE X LIKE wildcard expression actually generates REGEXP behind your code.

    Also depending on your database, for example Oracle, some database support various REGEXP functions for more complex matching than simple "wildcard" filtering.

    Oracle has REGEXP_LIKE, REGEXP_INSTR, REGEXP_SUBSTR among others.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 22, 2017 2:32 PM
  • User-458598543 posted

    Hello,

    Thanks for your answer, the queries systems that your purpose are interessants but after research, I use the old reactually (updated) method "Match ... Against ...".

    Bye !

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 31, 2017 12:15 PM