1
2
3
4
/^(?:(\d)[ \-\.]?)?(?:\(?(\d{3})\)?[ \-\.])?(\d{3})[ \-\.](\d{4})(?: ?x?(\d+))?$/

# expanded version w/ comments
...

Ruby Phone number regex

by Lex, October 31, 2008 16:00, 3 refactorings, tagged with phone number, regex, regexp, regular expression

I wrote this regex for pars...

Aca17ffad5faa4b9f2ea9090b56a1c59 Talk
1
2
3
4
      res = []
      path_without_calculation.gsub(/\{(.*?)\}/) {|match|
        res << match[1.. match.size-2]
...

Ruby Extract text between {} bra...

by stephan, October 22, 2008 11:54, 4 refactorings, tagged with short, regexp, gsub

Can this be written shorten?

349779c687ad1de3e116f3a5feaf3f92 Talk
1
2
3
4
def writefile(file, *linedata)
	linedata.each do |line| 	
		file << line.join(",") + "\n"
...

Ruby Parsing non-delimited text

by thepanu, October 06, 2008 07:48, 1 refactoring, tagged with parsing, non-delimited, regexp, csv

I have large text-reports f...

98edd841bbc19903cd758722d9745f0b Talk