Hi guys! I want to share with you a regex to use as a patter for entering a route:
valid:
/something123
/something/somethingelse/thiselse
not valid:
/*-*-*-*-
/something/*=*-=
/something123/
The regex is:
/^(?:\/(?:[a-zA-Z0-9])+)+$/
Happy coding!
Me gusta compartir lo que aprendo, y aprender para compartir. «Learning is good but sharing is cool» (by LMB)
Hi guys! I want to share with you a regex to use as a patter for entering a route:
valid:
/something123
/something/somethingelse/thiselse
not valid:
/*-*-*-*-
/something/*=*-=
/something123/
The regex is:
/^(?:\/(?:[a-zA-Z0-9])+)+$/
Happy coding!
Sometimes you want to filter the rows that not follow a given format.
For example, it was my case. I didn't get the rows that follow this format: [0-9]-wordhere
So, I did this:
my_result = MyModel.where("id = 1 AND (my_column NOT REGEXP ? AND my_column NOT REGEXP ?)", "[0-9]-wordone", "[0-9]-wordtwo")
This line will be transleted to:
SELECT * FROM my_table WHERE (id = 1 AND (my_column NOT REGEXP '[0-9]-wordone' AND my_column NOT REGEXP '[0-9]-wordtwo'))
Easy, right?
Happy coding :)