skip to Main Content

In MySQL Regular Expression pattern matching function, there is a ‘match_type’ – ‘n’.

Which represents,
The . character matches line terminators. The default is for . matching to stop at the end of a line.

Could someone explain me how to use that match type?

Source:

I did not found such example those documentation.

2

Answers


  1. Chosen as BEST ANSWER

  2. It’s not clear what you are asking, but here’s an example of how to use match_type n and the effect it has:

    This produces no results, because . does not match a newline:

    select * from (select 'abcndef' bar) foo
    where regexp_like(bar,'abc.def');
    

    This produces a result, by specifying match_type n to cause . to match a newline:

    select * from (select 'abcndef' bar) foo
    where regexp_like(bar,'abc.def','n');
    

    fiddle

    The default is for . matching to stop at the end of a line.

    The documentation is poorly worded here; it seems to be assuming a .*, but the match_type applies to any ..

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search