regex

Regular Expression to mask any string matching 10 digits only in golang

梦想的初衷 提交于 2021-01-28 11:52:59
问题 Since golang regex does not support lookaheads, I was wondering is there any way i can create a regex that will mask any string having a 10 digit number. func main() { s := "arandomsensitive information: 1234567890 this is not senstive: 1234567890000000" re := regexp.MustCompile(`\d{10}`) s = re.ReplaceAllString(s, "$1**********$2") fmt.Println(s) } Is it possible to get an output like this "arandomsensitive information: 1234****** this is not senstive: 1234567890000000" Also any regex

invalid back reference in lookahead in c++ std::regex

冷暖自知 提交于 2021-01-28 11:51:54
问题 It seems that c++ std::regex doesn't support back reference in lookahead. http://www.regular-expressions.info only says that c++ doesn't support lookbehind,foreward reference and nested reference. I also scanned c++14 standard and found nothing. Too little information about c++ std::regex on web. #include <iostream> #include <string> #include <regex> using namespace std; int main(int argc, char **argv) { regex re("(a)xxx(?=\\1)"); smatch matchs; string str {"axxxa"}; if(regex_search(str

Redirect using Htaccess- URL has underscore and change it to a slash

僤鯓⒐⒋嵵緔 提交于 2021-01-28 11:47:25
问题 I've gone through a couple dozen answers but none seem to give me what I need, hopefully, someone can help me out here... My URL structure looks like this https://www.example.com/this-is-static/random_text_32-11 and I need to redirect to https://www.example.com/this-is-static/random/text_32-11 So it's always the underscore right after "random" that needs to redirect to a slash / Everything after the underscore is dynamic ( random_text_32-11 ) There are other URLs that look like the below and

How to extract apartment from address in Pandas

本小妞迷上赌 提交于 2021-01-28 11:46:59
问题 I have a rather messy data set that has a lot of inconsistencies and errors due to manually input data. I'm working on the address column of this dataset in pandas. What I would like to do is break the address column into 3 separate entities: 1) a column for the address 2) a column for the street number 3) a column for the apartment or unit number The data looks like the following: address ---------------------- 123 smith street #5234 5000 john ct 34 wood st apt# 23 523 fire road apt #87

How to extract content from <p> HTML tag [duplicate]

本秂侑毒 提交于 2021-01-28 11:38:09
问题 This question already has answers here : RegEx match open tags except XHTML self-contained tags (36 answers) Closed 1 year ago . I have the following HTML as input: <p>Hello</p> <p>How are you?</p> <div>Hello again</div> How can I only output "Hello" from this? (only content from the first p-tag). And how can I also access only the second p-tag content? So the output should be: string p1 = "Hello" string p2 = "How are you?" My code so far. Full error!!! Help! using System.Text

Regex to extend ISBN-10 and ISBN-13 to non-English speaking countries

ぐ巨炮叔叔 提交于 2021-01-28 11:31:09
问题 I am looking for a Regex to match a string which should: start with an optional 978- or 979- prefix continue with a digit have a permutation of exactly 7 digits and 2 hyphens, without 2 consecutive hyphens end with a sequence of digit, hyphen, digit (which can be an x ) NB.: Hyphens can be replaced (coherently) by spaces or not present altogether... Match: 9780309091695 0309091695 9790309091695 978030909169x 978-0-309-09169-5 978-1-84356-028-3 978-0-8044-2957-X 978-93-86954-21-4 978-0-943396

Regex to add string to beginning of every word based on condition

自古美人都是妖i 提交于 2021-01-28 11:23:36
问题 I have a string which looks like this someString = "#3Hello there! How many #4candies did you sell today? Do have any #4candies left?" lookupDict = {"Hello there": "#3", "candies": "#4"} Now I want to replace every terms in the string someString with #0 which are not in the dictionary lookupDict . I can't split by a space " " since this will make certain terms like Hello there appear as two different words Hello and there and that would never match my condition. Now I know to apply basic

Regex to replace all leading tab characters, each one with a single space [duplicate]

╄→гoц情女王★ 提交于 2021-01-28 11:18:41
问题 This question already has answers here : Replace all left spaces with a specific string (5 answers) What is the purpose of the 'y' sticky pattern modifier in JavaScript RegExps? (2 answers) Closed 2 months ago . I'm looking for a regex to replace all leading tab characters with a single space (one space for each leading tab character. // input text with two leading tab characters and two tab characters elsewhere in the text var input=" Some text containing tabs"; // A: console.log(input

is there a method of rule based matching of spacy to match patterns?

霸气de小男生 提交于 2021-01-28 11:17:32
问题 i want to use rule based matching i have a text like each word with POS: text1= "it_PRON is_AUX a_DET beautiful_ADJ apple_NOUN" text2= "it_PRON is_AUX a_DET beautiful_ADJ and_CCONJ big_ADJ apple_NOUN" so i want to create a rule based matching that extract if we have an ADJ followed by noun (NOUN) or an ADJ followed by (PUNCT or CCONJ) followed by an ADJ followed by a noun (NOUN) so, iwant to have in output : text1 = [beautiful_ADJ apple_NOUN] text2= [beautiful_ADJ and_CCONJ big_ADJ apple_NOUN

Which one of these cases involves backtracking?

你。 提交于 2021-01-28 11:12:21
问题 I am trying to study regex from multiple sources, but came across a confusion about backtracking, because one defines backtracking, that it means the state when a regex engine fail to match a pattern, so it backtracks to the position where the first atom was matched , so for example,to match cat in He captured a catfish for his cat the engine will step like this: It will search for c until it match at c in captured then the same for a but fail to match t with p the engine reset back to