Home > Mobile >  How do i match characters in regex?
How do i match characters in regex?

Time:03-26

I'm learning regex, and i'm trying to find characters that starts with a or z. The current regex sentence i'm using is ^[az], but as you can see in this image, it doesn't work correctly, it only list the strings that starts with a, but not the ones that starts with z. I already know that ^[az] means search the strings starting (^) with a OR z.. enter image description here

Thanks for your attention :)

CodePudding user response:

Anchors (^ and $) only match new lines in multi-line mode. Specifically for regex101 which you seem to use, it's the m option after your regex:

enter image description here

CodePudding user response:

^[a|z] if want either char that start with a or z, but here has no delimiter to separate words, [az] means either a or z would be valid case, but it happens only exactly 1 time

if I'm not mistaken

  • Related