Introduction Regular Expression part 1 by muhamad akbar bin widayat

09.56 Muhamad Akbar Bin Widayat 0 Comments

regex to transform StudlyCase to camelCase
regex to transform StudlyCase to camelCase (Photo credit: chris.corwin)
Hi, all
I will share you about learning regular expression(regex) . The concept to make regex is about determining pattern of string or word or anything that have pattern. What the first you do?.

I try to share to you about creating simple regex first. On making regex you should know what the pattern your string after that you should make from simple first regex. Because when you start with simple regex first is began to make you more complex regex.

1. I have string 
     "111-111".
    scenario pattern:
  • should the first word is integer
  • the first integer include only 3 number
  • include (-) after integer
  • after that should include only 3 number in last string.
2. After determining pattern, you should write the regex.
  • Add /^/ is means the start of first character
  • Add /\d{3}/ is means the string include only 3 number
  • Add /-/ is pattern of string
  • Add /\d{\}/ is means only 3 integer
  • Add /$/ is means end off line character
  • /Everybody stand back/
    /Everybody stand back/ (Photo credit: Lasse Havelund)
  • To show the quick reference about another simbol regex. please go to http://rubular.com/.

3. Show the regex is
/^\d{3}-\d{3}$/
4. To check this regex on:


I hope this article can help you.
Enhanced by Zemanta

0 komentar:

terimakasih komentarnya