# Re: Problem with reqular expression

**URL:** <https://www.ruby-forum.com/t/re-problem-with-reqular-expression/95155>\
**Category:** Ruby\
**Created:** [May 23, 2006, 12:50pm UTC](https://www.ruby-forum.com/t/re-problem-with-reqular-expression/95155 "2006-05-23T12:50:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 23, 2006, 12:50pm UTC](https://www.ruby-forum.com/t/re-problem-with-reqular-expression/95155/1 "2006-05-23T12:50:45Z")

</div>

fr Ilyas:

# I have this string:

# 

# Color1 R=144 G=248 B=255

# 

# Need regular expression for get R,G,B

# How I can simplify it:

# 

# lines.gsub!(/Color1 R=(\d+) G=(\d+) B=(\d+)/) {

# puts $1

# puts $2

# puts $3

# }

irb(main):026:0\> s = “Color1 R=144 G=248 B=255”  
=\> “Color1 R=144 G=248 B=255”  
irb(main):030:0\> r,g,b=(/R=(\d+)\s+G=(\d+)\s+B=(\d+)/).match(s).captures  
=\> [“144”, “248”, “255”]  
irb(main):031:0\> r  
=\> “144”  
irb(main):032:0\> g  
=\> “248”  
irb(main):033:0\> b  
=\> “255”
