Regular expression on the marked words

Given a string representing a sentence like this followed by tagging the string using OpenNLP. String sentence = "His plays remain highly popular, and are constantly studied."; I get this below. My question is how do I know apply a regular expre

sed or perl regex replace the section in the file

I have a file, and am trying to regex to remove the the lines that has: flannel: interface: $private_ipv4 etcd_endpoints: {{ .ETCDEndpoints }} I tried to to use this perl command, it ends up removing everything from #cloud-config till -- name: docker

RegexHow can I validate an underscore between letters

How can i allow any word character and the underscore should have a letter and a number between it. example: ab2_sb, s_s, but it shouldn't allow sdc_ or _s2 this is my code [a-zA-Z0-9_]{6,255}$ I'm using regex on javascriptYou need to separate the ch

Verification for only a-z and A-Z characters in Javascript

I am trying to get my javascript file to validate input "name". I have a regex for the allowed characters set as /^[A-Za-z]+$/. However, whenever the function gets to the verification of the characters, it does not show anything at all. I have b

Clean and Unclean Strings in Python

I have a messy inventory list (around 10K) to clean and I am some problems of using regular expression in Python to achieve this. Here is a small sample of my list: product_pool=["#101 BUMP STOPPER RAZOR BUMP TREATMENT SENSITIVE SKIN FORMULA", &

How to delete everything between a key phrase and an end tag?

I am trying to strip everything between a key phrase and ending tag but for some reason it is not working. I always get blank data. I've tried many different ways but no luck. Basically I have a script that connect to IMAP and store emails into MySQL

Regex correspondence of email address || a word

I have an input field that will take a keyword input as either an email address or a plain text keyword. I just want to validate that there's no unusual or unsafe characters. My normal validation expression I use for emails on the webform is: "\w+([-

How to undo all methods corresponding to regex

I got a class and a module (names are changed for security issues) class Model < ActiveRecord::Base include Identifier ... end module Identifier def self.included base base.instance_eval do def find(*args) #new find implementation end end end The aim

The RegEx force quantifier is valid

I am struggling to get my regex validation for name initials to work. I have the following code: // S.P. of Sp.A. string voorletters = "S.P.aAa"; // This should be invalid string regexPattern = "^([A-Z]{1}[.]|[A-Z]{1}[a-z]{1,}[.])*"; v

Perl regular expression {} quantify several matches

Im trying to parse a file wherein each line has 3 floats(1, +1.0 -1.0 being valid values) and while the regular expression in the snippet matches a float value, I'm not sure how I should be using the Perl quantifier {n} to match multiple floats withi

How to analyze this regular expression?

I have data like this simm_ar_stg --want simm_ca_bs --want simm_std --dont want I try this but it does not work simm_(a-zA-Z)(a-zA-Z)_.* any idea how to parse this ?This expression will do the work for you: simm_[a-zA-Z]{2}_[a-zA-Z]+ assuming you nee

How to match the backslash to the beginning of the line in PHP

After seeing some errors showing up in our apache logs, I've been trying to figure out 'why'. The errors related to a preg_match command where I was trying to find strings that started with a backslash character: preg_match('/^\\/',$str) It was repor

Regex - Ignore parts of the string in the match

Here's my string: address='St Marks Church',notes='The North East\'s premier...' The regex I'm using to grab the various parts using match_all is '/(address|notes)='(.+?)'/i' The results are: address => St Marks Church notes => The North East\ How c

Find only the first match in a regex search

Regex messageServerRegex = new Regex(@"([0-9\-]{10})\ ([0-9:]{8})\ \[TEXT\]\ (\[Server\])\ ([^\[]*)"); if (messageServerRegex.IsMatch(rchConsoleText)) { var infoMatches = messageServerRegex.Split(rchConsoleText); Console.WriteLine("Date: {0

Django URLS, using a? in the URL

I am trying to do some Django URL matching. i want a few urls where i have,, etc. I can't figure out how to URL match these expressions: I'm very new to Django and never used Reg E

PHP preg_match_all - how to get HTML content?

$Content contains HTML document $contents = curl_exec ($ch) I need to get a content from: <span class="Menu1">Artur €2000</span> It's repeated several times so I want to save it into Array I try to do that this way: preg_match_all('&

Combination regex and strtotime

I'm trying to improve the readibility of a published date being pulling in from a twitter XML file. Currently the time date being displayed is 2012-02-10T14:20:08Z I have applied a regex to this and now displays 2012-02-10 14:20:08 GMT Now all i need

Test if a regular expression is valid in PHP

I am writing a form validation class and wish to include regular expressions in the validation. Therefore, the regex provided isn't guaranteed to be valid. How can I (efficiently) check that the regex is valid?Use the pattern in your preg_* calls. If

Regular Expression Get USA Postal Code

How do I "extract" zip code (US) from the following string? import re address = "Moab, UT 84532" postal_code = re.match('^\d{5}(-\d{4})?$', address) print postal_code Firstly, you are using match, which will match only from the beginni

Regex Expression for Name Validation

This question already has an answer here: Regular expression for validating names and surnames? 12 answers What is the regular expression to check against when validating someone's name? I was thinking a-z, A-Z, dash, space, and apostrophe. Any thing

Help with PHP regex

I'm trying to replace all the letters and spaces after the first two, using PHP's preg_replace. Here is my failed attempt at doing so: echo preg_replace('/^[a-zA-Z]{2}([a-zA-Z ])*.*$/i','','FALL 2012'); //expected output is "FA2012", but it outp

jquery / javascript - Simple split () problem

if ($(".productpage .description").html() != null) { var textToHide = $('.productpage .description').html().split('<br class="breakHere">')[1]; var visibleText = $('.productpage .description').html().split('<br class="bre

Regex matches any characters before in php

I need the regex expression to match everything from beginning till I encounter one of these characters ; or [ or { or ( In case these characters are not there then the whole word needs to be matched.. I am using preg_match("/(.*?)(?=(;|\[|\(|{|))/&q

Ruby 1.9: Regular expressions with unknown input encoding

Is there an accepted way to deal with regular expressions in Ruby 1.9 for which the encoding of the input is unknown? Let's say my input happens to be UTF-16 encoded: x = "foo<p>bar</p>baz" y = x.encode('UTF-16LE') re = /<p>(.*

Make clickable links with regex

Is there a regex out there that can find a string that contains a word that starts with either http:// or www and wrap it with <a>$1</a>? Been googling but I can't seem to find a ultimate one. Another question, Could you somehow make it ignore