Questions tagged [rubular]

A Ruby-based regular expression editor and tester.

A Powerful and most efficient Domain for testing Regular Expressions.

Website: http://rubular.com/

66 questions
1
vote
1 answer

Multiline java exception regex in rubular

I've these kind of logs in an application and I want to parse them. I've created a regex but it doesn't work as expected as it doesn't parse the full stack trace in the log. Here's my current…
Waseem Hassan
  • 233
  • 2
  • 10
1
vote
3 answers

Select a string in regex with ruby

I have to clean a string passed in parameter, and remove all lowercase letters, and all special character except : + | ^ space => <=> so i have this string passed in parameter: aA azee + B => C= and i need to clean this string to have this…
1
vote
2 answers

replace specific text in ruby using regex

In ruby, I'm trying to replace the below url's bolded portion with new numbers: /ShowForum-g1-i12105-o20-TripAdvisor_Support.html How would I target and replace the -o20- with -o30- or -o40- or -o1200- while leaving the rest of the url intact? The…
Horse Voice
  • 8,138
  • 15
  • 69
  • 120
1
vote
4 answers

Regex to extract last number portion of varying URL

I'm creating a URL parser and have three kind of URLs from which I would like to extract the number portion from the end of the URL and increment the extracted number by 10 and update the URL. I'm trying to use regex to extract but I'm new to regex…
Horse Voice
  • 8,138
  • 15
  • 69
  • 120
1
vote
1 answer

Unable to split data properly with Ruby Regex Rubular

I am trying to organize and break up contents within emails that has been extracted through Net::POP3. In the code, when I use p mail.pop I get ****************************\r\n>>=20\r\n>>11) <> Summary: Working with Vars on Social Influence…
chickensmitten
  • 477
  • 6
  • 16
1
vote
1 answer

Difference in regex between Python and Rubular?

In Rubular, I have created a regular expression: (Prerequisite|Recommended): (\w|-| )* It matches the bolded: Recommended: good comfort level with computers and some of the arts. Summer. 2 credits. Prerequisite: pre-freshman standing or…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
1
vote
2 answers

Adding words in regex

I have this string below: "\n - MyLibrary1 (from ‘repo_name’, branch ‘master’)\n - AFNetworking (= 1.1.0)\n - MyLibrary2 (from ‘repo_name’, branch ‘master’)\n - Objective-C-HMTL-Parser (= 0.0.1)\n\n" Of which I wish to extract the data and…
tech_human
  • 6,592
  • 16
  • 65
  • 107
1
vote
3 answers

Regex for huge string

I have the below string: "\n - MyLibrary1 (= 0.10.0)\n - AFNetworking (= 1.1.0)\n - MyLibrary2 (= 3.0.0)\n - Objective-C-HMTL-Parser (= 0.0.1)\n\n" I want to create a JSON like this: { "MyLibrary1": "0.10.0", "AFNetworking":…
tech_human
  • 6,592
  • 16
  • 65
  • 107
1
vote
2 answers

Match text exactly after n lines

Using regular expression match the text exactly after n lines. In the below example, I want to ensure that request is exactly after 3rd line from id: 1 Example: signal { id: 1 files: 1.bin major: 338013710701 request { reqId: 101 …
MIZ
  • 385
  • 1
  • 14
1
vote
1 answer

Match only the matching block (ignore if the the starting word appears before the matching block)

I have my input as follows, Input StatusMsg: seqId: 14043 timestamp: 140707 dId: "Sa01" msgType: SEQUENCE eventType: UPDATE_CMD devContext { context: IDLE operationalMode: 1 logHistory { start: 1404387563607 end: 1404387563616 …
MIZ
  • 385
  • 1
  • 14
1
vote
1 answer

How to match text in between two words(a..b) till the first occurence of the ending word(b)

Can anyone help me to match the text between From and first occurrence of Subject from the following set of lines, Input Random Line 1 Random Line 2 From: person@example.com Date: 01-01-2011 To: friend@example.com Subject: This is the subject…
MIZ
  • 385
  • 1
  • 14
1
vote
2 answers

Ruby Regex Rubular vs reality

I have a string and I want to remove all non-word characters and whitespace from it. So I thought Regular expressions would be what I need for that. My Regex looks like that (I defined it in the string class as a…
tomet
  • 2,416
  • 6
  • 30
  • 45
1
vote
4 answers

I need a regex to find a url which is not inside any html tag or an attribute value of any html tag

I have html contents in following text. "This is my text to be parsed which contains url http://someurl.com?param1=foo¶ms2=bar some text and a url http://someotherurl.com test 1q2w …
krunal shah
  • 16,089
  • 25
  • 97
  • 143
1
vote
0 answers

Inserting new associations after the last associations in a file in a Rails generator using a Regexp

I've been trying to insert a few new associations into an existing model using the insert_into_file method in a custom generator. For aesthetic reasons, and to avoid hard-coding anything, I would like to insert them after the last ones found. I…
jordanpg
  • 6,386
  • 4
  • 46
  • 70
0
votes
3 answers

Rubular/Ruby discrepancy in captured text

I've carefully cut and pasted from this Rubular window http://rubular.com/r/YH8Qj2EY9j to my code, yet I get different results. The Rubular match capture is what I want. Yet desc_pattern = /^
(.*\n?.*)\n/ if desc =~ desc_pattern puts…
tom
  • 541
  • 1
  • 5
  • 16