Extract a string between special characters in a csv column

I want to extract userhandles from retweets, ie; any username between "RT @username:xyzxyzxyz" to a new column. I did the following df = pd.read_csv("string.csv") for index,row in df.iterrows(): df['Influencers'] = df['Tweet'].str.extr

Python regular expression with spaces runs so slowly

import re import requests import bs4 import datetime from urllib import quote import urllib2, cookielib class smzdm(object): def __init__(self): pass def getoff(self,keyword): headers={'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,i

Using the bash program with argument inside a sed

I have a small SED question to ask you. But first of all, I know there are other ways to do what I want (I've already made a small python script to do that), but for my own curiosity, I'd like to know if there is a way to do that with SED. So, e.g. :

Comapre string components with array values

I have one string in PHP that forms HTML select box. I am also having one array. What I want is: I want to compare options of the select box with array elements and only keep the options in select box that match with array elements. Following is the

Regex - First Instance of Time in a Chain

I am trying to build a regular expression that would pull the first time out of a string. The issue is the time format is not standardized. Here are the possible variations. ':' with 1 hour digit before the ':' (ex. 9:00 pm) ':' with 2 hour digits be

Perl - split control with regex - digital split and strings

My data look as follows: 20110627 ABC DBE EFG 217722 1425 1767 0.654504367955466 0.811585416264778 -0.157081048309312 I am trying to split in such a way that I keep numeric values in one cell, and strings in one cell. Thus, I want "20110627" in

Regex Pattern to recover text between tags

my string is: $p['message'] = '[name]Fozia Faizan[/name]\n[cell]03334567897[/cell]\n[city]Karachi, Pakistan[/city]'; What I want to do is to use REGEX pattern so as to get the result like this: Name: Fozia Faizan Cell #: 03334567897 City: Karachi, Pa

Ruby: Remove something between [] a string with a regex

I got thoses 2 strings : [ Nope ] I need that I need this And I want to have only 'I need that' & 'I need this' So I tried regex like that : [ Nope ] (.+)$|(.+) By the way, this doesn't work but [ Nope ] (.+)$ You can do this: string = '[ Nope ] I ne

The regular expression gets the last characters

This question already has an answer here: Regular Expression for getting everything after last slash 5 answers I want to write a regular expression which will take the characters from the last "slash" "/" to the right. Exemple1 : http:

Foreach template tag in PHP

I made the following code to replace template tags. It works fine for 1 item, but I am looking for a solution to replace every item listed. The code only replaces the template tags with the content of item 2. $template = ' <div style="border:1px s

Print Perl Command Line - Test Regexp at the Command Line

I'm very new to Perl and I'm trying to figure out just how to get this thing to work. I found an example in this thread: Perl Regex - Print the matched value Here is the example I'm trying to work with: perl -e '$str="the variable Xy = 3 in this case

Test at least one lowercase and one uppercase

How would I check a string contains at least one lowercase and at least one uppercase using awk. My attempt: ^.*[a-z]+[A-Z]+.*$|^.*[A-Z]+[a-z]+.*$ With awk you can use the logical operator && and test for both lowercase and uppercase using their r

Regular expression to merge two lines

I'm trying to find a regular expression to merge the second and third lines. There's no space after each line (only \r\n). I can look for lines that start with letters then merge them with the line above, but this would force me to match the first le

Regex string to uncompressed decimal point

I have the following string: {lorum=Vestibulum id ligula porta felis euismod semper. Sed posuere\, consectetur est at lobortis.,ipsum= Cras mattis consectetur purus sit amet fermentum. Nulla vitae elit libero, a pharetra augue.} Now, what I want to g

RegEx digital with length

How I can to create a Numeric Regex with decimal separator, but also limit the length I create this: ^[0-9]([0-9]*[.]?[0-9]){1,10}$ Then 1234567890.1234567890 is valid, but is using 20(+1 -> decimal separator) characters. How I can do to limit to 10

Write Regex in Java

I have one string "110:name:[email protected]". I want to create a regex such that the values before first colon should be only numerics i.e. 110, values before second colon should be only alphabets and third part should have a valid em

Delete dynamic text from NSString

I have a NSString with some text that i want to remove,this is the text that i want to remove from the NSString: Textid="more-98989"> the number can change to another number. Any way to do it ? Did i need Regex for this?You can definitely do

Regular Expressions - Combine the greedy and lazy mode

For example, for a string: http://www/host/a/b/c/topic/d/e/f/topic/last.html I want to get value of "b" and "c", which are value of string before FIRST "topic". If I use: .+/(.+)/(.+)/topic/(.+), I will get "e" and

Analyze CSV files using Regex in Java

I'm trying to create a program, which reads CSV files from a directory, using a regex it parses each line of the file and displays the lines after matching the regex pattern. For instance if this is the first line of my csv file 1997,Ford,E350,"ac, a

Regular Expression - Find and Replace

I'm new to regular expression and have come across a problem. I want to do a search and replace on a string. Search for an instance of -- and ' and replace it with - and `, respectively. Example Current String: Hi'yo every--body! Replaced String: Hi`

Replace specific characters with Regex .net

I have a small Regex here where I am removing all the white spaces from within a file and replacing them with '-'. I want to also replace other characters with '-' such as ',' and '_'. How can I list these characters in my regex? Regex r = new Regex(

regexp exec pattern before returning Null

My test RegExp with pattern before returns null. How do I get it to return 2? s = new RegExp(/(?=ID\=)(\d+)/).exec("ID=2"); (?=) is a lookahead assertion. You'd want to use lookbehind, which JavaScript does not support. This, however, will work

Groovy Regex illegal characters

I have a Groovy script that converts some very poorly formatted data into XML. This part works fine, but it's also happily passing some characters along that aren't legal in XML. So I'm adding some code to strip these out, and this is where the probl

C # regex extract tags

Say I have a few string like Hi my name is <Name> Hi <name>, shall we go for a <Drink> Is it possible to get the tags captured through c# Regex? like <Name>, <drink> etc? I am not able to get it right..Sure: Regex.Matches(myS

How to make a multiline search using a regular expression?

I am new to regular expressions. I want to do multiline search. Here is the example of what I want to do: Suppose I have following text: *Project #1: CVC â€" Customer Value Creation (Sep 2007 â€" till now) Time Warner Cable is the world's leadin