Jump to content
Che

Regex match words of 3 to 16 chars ?

Recommended Posts

Am astea ca si date de analizat:

my-us3r_n4m3

gigel

th1s1s-wayt00_l0ngt0beausername

Si vreau cu regex sa-mi aleaga doar cuvintele care au intre 3 si 16 litere, astfel rezultatul ar fi:

my-us3r_n4m3

gigel

fara ultimul.

Mi-am tot stors creierii si tot nu am reusit. Am ajuns pana la urma la expresia asta:

\w[a-zA-Z0-9_-]{3,16}

Care are ca rezultat asta:

my-us3r_n4m3

gigel

th1s1s-wayt00_l0n

gt0beausername

Unde am gresit ?

Multumesc anticipat !

Link to comment
Share on other sites

Am astea ca si date de analizat:

Si vreau cu regex sa-mi aleaga doar cuvintele care au intre 3 si 16 litere, astfel rezultatul ar fi:

fara ultimul.

Mi-am tot stors creierii si tot nu am reusit. Am ajuns pana la urma la expresia asta:

\w[a-zA-Z0-9_-]{3,16}

Care are ca rezultat asta:

Unde am gresit ?

Multumesc anticipat !

Cred c? ar merge asta:


(?=^)\S{3,16}(?=$)

G?se?te tot ce este cuprins între 3 ?i 16 caractere (f?r? spa?ii) pe o singur? linie.

PS:

Seteaz? modificatorii pe G ?i M dac? vrei s?-?i g?seasc? de pe toate linile.

Edited by H3xoR
Link to comment
Share on other sites

Aici vad ca nu merge, si mai am si un program cu regex si nici pe ala nu merge:

RegExr: Learn, Build, & Test RegEx

si nici aici:

Regex Tester and Debugger Online - Javascript, PCRE, PHP

Fi serios..

?i-am scris mai sus s? setezi acei modificatori (gm).

Uite c? mie-mi merge ?i pe site-urile alea:

2i7u1z6.png

28tar21.png

Scuze c?-?i spun îns? nu e?ti capabil s? te descurci nici cu „mur? în gur?”.

Sear? bun?.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...