Freelancer job part time jobs

InstaForex
  • Home
  • Jobs hiring now
  • FAQ
  • Contact

Ruby, substituting a regex matches in a string of matches with the same regex

September 4, 2008 by Freelance

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • More
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)

My Mother that title has been good to me:)

This is a mental note and maybe if you do not know that I speak not for you and you know that I speak already know.

I try to replace a part of a String by another party who is in the same String .

I mean, I have this “I like the heavy, and I do not like the country” ‘to’ and I want to get this one “I like the country and I do not like the heavy “.

It can be done well:

>>  "I like the heavy, and I like the country not ". gsub ( / I like  (< And >.*) I do not like the (.*)/,  'I like  \ 2  and I do not like the  \ 1 ' ) 
=> "I like country and I do not like the heavy "

Where

\ 1

and \ 2 are occurrences of the (.*).
The example may seem a bit silly, but this has been helpful to me very well to stay with the contents of a tag

html

:

>>

 " Content ". gsub ( /.* body [^>]*>(.*) \ / body < >>.*/ mix, ' \ 1 ' ). strip  
=> "Content "

What can be solved in many other ways but I have found the easiest.

I write this note mentally for what little that is intuitive to use

‘\ 1’ string as a substitute because it is assumed that the strings in single quotes are not interpreted …

Another thing is that I always had to google solutions like this:

>>  "I like the heavy, and I like the country not ". gsub ( / I like  (< And >.*) I do not like the (.*)/,  "I like # ($ 2) and not I like the # $ (1) " ) 
=> "I like country and I do not like the heavy "

And although it seems that no works is because the contents of

$ 1

and $ 2 has caught the gsub earlier rather than this:

>>

  "I like the music and I do not like flamenco ". gsub ( / I like  (< And >.*) I do not like the (.*)/,  "I like # ($ 2) and not I like the # $ (1) " ) 
=> "I like country and I do not like the heavy"
>> "I like the music and I do not like flamenco ". gsub ( / I like (.*< >) And I do not like the (.*)/, "I like # ($ 2) and I do not like the $ 1 (# ) " )
=> "I like flamenco and I do not like the music "

100% Bonus

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • More
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)
Ruby, sanitized your titles in 2 lines.
String position and strops in PHP – php tutorial
String explode in PHP – php tutorial
Letters – Ruby on Rails tutorial
Variables and assignement – Ruby on rails tutorial
First script in Ruby on rails – tutorial practice
Java Socket’s Fundamentals – Ruby on Rails tutorial
More about methods – ruby on Rails tutorial
Classes – Ruby on Rails tutorial
Writing your own methods – Ruby on Rails tutorial
Arrays and Iteratiors – Ruby on Rails tutorial
Blocks and Procs – Ruby On Rails tutorial
How to install Ruby on rails ?

Filed Under: Freelancer job news

Earn money as trader

img

Earn from home ads

Work from home ads

Work from home as instaforex forex trader

Freelance categories

  • Earn money as webmaster
    • Advertising
    • Affiliate program
    • Amazon
    • Bidvertiser
    • Blogging
    • Facebook
    • Google Adsense
    • Hosting
    • Komoona
    • LinkedIn
    • Neteller
    • SEO
    • Skrill Moneybookers
    • Twitter
  • Education
    • How to do
    • Job description glossary
    • Wordpress how to do
  • Freelancer advice tips
    • Forex trading from home
      • Affiliate programs
        • 500affiliates
        • Avapartner
        • Etoropartners affiliate program
        • HotForex Affiliate program HFaffiliates
      • Binary options trading
        • Anyoption
        • OptionBit Review
        • TradeRush
        • Ubinary
        • Yesoption
      • Facebook IPO price – buy facebook stock
      • Forex brokers reviews
        • 4XP Review
        • Alpari Russia Review
        • Alpari UK
        • AvaTrade Review
          • AvaFx Review
        • DeltaStock Review
        • Directfx Review
        • DukaScopy Review
        • Easy Forex Review
        • Etoro Review
        • ETX Capital Review
        • Exness
        • Forex.com Review
        • Forex4you
        • ForexYard Review
        • FXCM Review
        • FXDD Review
        • FxOpen Review
        • Fxpro Review
        • HiWayFX review
        • Hotforex Review
        • HY Markets Review
        • IC Markets Forex Review
        • IFC Market
        • IForex Review
        • IG Markets
        • Instaforex Review
        • Ironfx Review
        • Keystock Review
        • LCG review
        • Liteforex broker
        • Marketiva Review
        • Markets.com Review
        • NordFx Review
        • Pepperstone Review
        • Plus500 review
        • Roboforex
        • SwissQuote Bank Review
        • Thinkforex
        • UFX Markets review
        • Windsor Brokers Review
        • XeMarkets Review
        • xForex
        • Xtrade Review
        • Youtrade FX Review
        • Zulutrade Review
    • Freelance glossary
    • Freelance Programming tips
    • Learn about programming
      • C++
      • Linux
      • PHP
      • Ruby on rails
      • SQL
    • Top freelance websites
    • Web Design tips
    • Work from home business
    • Writing tips
  • Freelancer job news
    • Job advice
    • Thinking
    • Worldwide job offers
  • IT news
  • Jobs

Best Forex Brokers Reviews

  • Avafx Review – how to earn in forex market using Avafx Forex Broker
  • Avatrade Review
  • eToro Review
  • Alpari NZ Review
  • InstaForex Review
  • DukaScopy Review – Swiss bank Forex broker
  • Forex.com Review – how to earn money in forex market as trader
  • Ironfx Review
  • FXCM Review
  • FxOpen Review
  • Hotforex Review
  • Markets.com Review
  • UFX Markets Review
  • Zulutrade Review – earn money using free forex signals where forex experts trade for you
  • Exness forex broker Review
  • Fxpro Review
  • LiteForex forex broker review
  • NordFx Review and bonus
  • Roboforex forex broker Review
  • XM.com Review - Xemarkets forex broker review

Navigation

  • Home
  • Jobs hiring now
  • FAQ
  • Contact

Languages

  • Arabic language
  • Bengali language
  • Communiqué de presse
  • China language
  • Pressemitteilung
  • Japanese language
  • Comunicado de imprensa
  • Russian language
  • Presione soltar
  • Turkish
  • Comunicato stampa
  • Hindi language

Recent articles

  • IronFX Review
  • How to earn money as freelancer ?
  • LCG broker Review
  • Forex vs. stocks – Which is a Better for Trading ?
  • Thinkmarkets Review
Freelancer job - Copyright 2007
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.