regex-lookarounds

Match unescaped quotes in quoted csv

空扰寡人 提交于 2021-02-07 07:38:59
问题 I've looked at several of the Stack Overflow posts with similar titles, and none of the accepted answers have done the trick for me. I have a CSV file where each "cell" of data is delimited by a comma and is quoted (including numbers). Each line ends with a new line character. Some text "cells" have quotation marks in them, and I want to use regex to find these, so that I can escape them properly. Example line: "0","0.23432","234.232342","data here dsfsd hfsdf","3/1/2016",,"etc","E 60"","AD"8

Regular expression to match strings that do NOT contain all specified elements

浪尽此生 提交于 2021-02-05 06:30:51
问题 I'd like to find a regular expression that matches strings that do NOT contain all the specified elements, independently of their order. For example, given the following data: one two three four one three two one two one three four Passing the words two three to the regex should match the lines one two , one three and four . I know how to implement an expression that matches lines that do not contain ANY of the words, matching only line four : ^((?!two|three).)*$ But for the case I'm

JS Regex lookbehind not working in firefox and safari

丶灬走出姿态 提交于 2021-02-05 05:50:13
问题 I have this following regex which is working in chrome but causes an error in firefox or safari. I need to modify it to make it work. Can anybody help out a poor soul? Thanks in advance! regex: /(?=<tag>)(.*?)(?<=<\/tag>)/ Basically, I have to match any char in between <tag> and </tag> and need to retain both tags. I used this expression as an argument to array.split. input: "The quick brown <tag>fox</tag> jumps over the lazy <tag>dog</tag>" operation: input.split(regex) output: ["The quick

Look behinds: all the rage in regex?

╄→尐↘猪︶ㄣ 提交于 2021-02-04 22:35:48
问题 Many regex questions lately have some kind of look-around element in the query that appears to me is not necessary to the success of the match. Is there some teaching resource that is promoting them? I am trying to figure out what kinds of cases you would be better off using a positive look ahead/behind. The main application I can see is when trying to not match an element. But, for example, this query from a recent question has a simple solution to capturing the .* , but why would you use a

Match pattern not preceded or followed by string

让人想犯罪 __ 提交于 2021-01-29 09:12:20
问题 I need to match any sequence of 9 digits or more, that is not preceded OR followed by 2 uppercase letters, anywhere in a text: OG237338070BR // should NOT match og237338070br // should match oG237338070bR // should match G237338070BR // should match OG237338070B // should match G237338070B // should match asd OG237338070BR asd // should NOT match asd G237338070BR asd // should match asd OG237338070B asd // should match asd OG237338070Basd asd // should match asd OG237338070BRasd asd // should

Regex expression for file name with 2 underscores and 3 segments

和自甴很熟 提交于 2021-01-29 07:30:57
问题 I need a regex expression that will select files with particular file name format from the file list of properties files. I need to select files with file names with following file format: <app_name>_<app_version>_<environment>.properties here <app_name> can be any alphanumeric with special character <A-Z/a-z/0-9/special char> like abc123 or app1-1 here <app_version> can be any alphanumeric with special character <A-Z/a-z/0-9/special char/float value> like abc or even float/integer/string 1.0

Is it possible to rename PascalCase1.wav to kebab-case-1.wav with a single perl regex?

时间秒杀一切 提交于 2021-01-29 00:45:00
问题 Here is a sample of my data: SomePascalCase.wav ThingsThat1.wav Are.wav Here.wav Here is the result I'm looking for: some-pascal-case.wav things-that-1.wav are.wav here.wav Here is what I used: for f in *.wav; do mv "$f" $( echo "$f" | perl -pe 's/([A-Z])([a-z]+)(?=[0-9A-Z])/\L\1\2-/g' | perl -pe 's/([A-Z])([a-z]+)(?=.wav)/\L\1\2/g' ) done Is it possible to consolidate the two regular expressions I used into a single one? 回答1: You wouldn't really use a regex substitution here. You would use

Is it possible to rename PascalCase1.wav to kebab-case-1.wav with a single perl regex?

我的梦境 提交于 2021-01-29 00:40:55
问题 Here is a sample of my data: SomePascalCase.wav ThingsThat1.wav Are.wav Here.wav Here is the result I'm looking for: some-pascal-case.wav things-that-1.wav are.wav here.wav Here is what I used: for f in *.wav; do mv "$f" $( echo "$f" | perl -pe 's/([A-Z])([a-z]+)(?=[0-9A-Z])/\L\1\2-/g' | perl -pe 's/([A-Z])([a-z]+)(?=.wav)/\L\1\2/g' ) done Is it possible to consolidate the two regular expressions I used into a single one? 回答1: You wouldn't really use a regex substitution here. You would use

solr DIH: RegExTransformer

拜拜、爱过 提交于 2021-01-28 05:12:19
问题 Currently, I need to apply a transformation on bellow third column: ACAC | 0 | 01 ACAC | 0 | 0101 ACAC | 0 | 0102 ACAC | 0 | 010201 I need to transform "010201" to "01/02/01" . So first I need to: trim all ending 0 characters split each 2 numbers and add "/" character. The context of this transformation is inside solr data import handler transformers, but it's using java regex library internally. Is there anyway to get that? I've tried using this regex: Currently, I need to apply a

Negative lookbehind in a regex with an optional prefix

亡梦爱人 提交于 2021-01-27 15:51:21
问题 We are using the following regex to recognize urls (derived from this gist by Jim Gruber). This is being executed in Scala using scala.util.matching which in turn uses java.util.regex : (?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?!js)[a-z]{2,6}/)(?:[^\s()<>{}\[\]]+)(?:[^\s`!()\[\]{};:'".,<>?«»“”‘’])|(?:(?<!@)[a-z0-9]+(?:[.\-][a-z0-9]+)*[.](?!js)[a-z]{2,6}\b/?(?!@))) This version has escaped forward slashes, for Rubular: (?i)\b(((?:https?:(?:\/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?!js)