Ring Documentation Walkthrough #8.3 – substr()

We can do a lot with this function:

  1. Find Substring position.
    see substr('Al Ahly SC', 'Ahly') #output: 4
  2. Get string from specific position to the end.
    position = substr('Al Ahly SC', 'Ahly')
    see substr('Al Ahly SC', position) #output: Ahly SC
    
  3. Get specific amount of characters from specific position.
    str = 'Al Zamalek SC'
    position = substr(str, 'Zamalek')
    see substr(str, position, 7) #output: Zamalek
    
  4. Replace words or characters inside a string.
    str = `Social Network`
    see substr(str, 'Network', 'Life') + nl #output: Social Life
    
    #Ignore the case by adding the parameter 1 will convert the string to lower case.
    see substr(str, 'network', 'life', 1) + nl #output: social life 
    

 

DONE!, This is the end of the strings chapter, see you in the new chapter.

amrESSAM.

Advertisements
Ring Documentation Walkthrough #8.3 – substr()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s