bonjour
de cette facon
<!DOCTYPE html> <html> <head> <script> function str(){ var nom="fils_5" nom=nom.substring(5, nom.length); alert(nom) } </script> </head> <body> <button onclick="str()">appui</button> </body> </html>
ou
<!DOCTYPE html> <html> <head> <script> function str(){ var nom="fils_5" nom=nom.replace("fils_",""); alert(nom) } </script> </head> <body> <button onclick="str()">appui</button> </body> </html>
ou
<!DOCTYPE html> <html> <head> <script> function str(){ var nom="fils_5" var index_debut = nom.indexOf("_")+1; nom=nom.substring(index_debut, nom.length); alert(nom) } </script> </head> <body> <button onclick="str()">appui</button> </body> </html>
ou
<!DOCTYPE html> <html> <head> <script> function str(){ var nom="fils_5" var index_debut = nom.lastIndexOf("_")+1; nom=nom.substring(index_debut, nom.length); alert(nom) } </script> </head> <body> <button onclick="str()">appui</button> </body> </html>
27 juil. 2023 à 23:49
Salut,
tu as oublié la version regex ;)
28 juil. 2023 à 10:36
je suis pas un bon en regex
28 juil. 2023 à 12:02
;)
Je ne sais pas comment ça d'implémente en js, mais si
Ça pourrait être
Un exemple ici https://regex101.com/r/HDrvYA/1
Modifié le 29 juil. 2023 à 18:11
et hop un de plus