regex

Regex - Remove single whitespace

谁说胖子不能爱 提交于 2021-01-28 07:41:44
问题 I´ve got a string that looks like this: "T E S T R E N T A L A K T I E B O L A G" And I want it to look like this: "TEST RENTAL AKTIEBOLAG" But I can´t seem to find the right regex expression for my problem. I would like to remove one single whitespace between each character. Kind Regards / H 回答1: You can use the regex: \s(\s)? And replace with $1 . regex101 demo 回答2: An alternative solution to @Jerry's answer: preg_replace('# (?! )#','',$text) regex101 demo 3v4l.org demo 回答3: you couldnt use

How to return a string if a re.findall finds no match

自古美人都是妖i 提交于 2021-01-28 07:26:50
问题 I am writing a script to take scanned pdf files and convert them into lines of text to enter into a database. I use re.findall to get matches from a list of regular expressions to get certain values from the tesseract extracted strings. I am having trouble when a regular expression can't find a match I want it to return "Error." So I can see that there is a problem. I have tried a handful of if/else statements but I can't seem to get any to notice the None value. from wand.image import Image

Firebase Rules Regex Birthday

我们两清 提交于 2021-01-28 07:25:31
问题 I am trying to validate birthdays using the following regex: ^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$ This regex works when tested in an online regex tester, but when I try to use this regex inside my firebase

Regex - Remove single whitespace

两盒软妹~` 提交于 2021-01-28 07:18:54
问题 I´ve got a string that looks like this: "T E S T R E N T A L A K T I E B O L A G" And I want it to look like this: "TEST RENTAL AKTIEBOLAG" But I can´t seem to find the right regex expression for my problem. I would like to remove one single whitespace between each character. Kind Regards / H 回答1: You can use the regex: \s(\s)? And replace with $1 . regex101 demo 回答2: An alternative solution to @Jerry's answer: preg_replace('# (?! )#','',$text) regex101 demo 3v4l.org demo 回答3: you couldnt use

How to include character in regular expression

南笙酒味 提交于 2021-01-28 07:11:45
问题 I have this text: x A1 ,A2-A4 xx, xxx A5 xxxx I have this regular expression: [A-Z]{1,3}-?\d{1,3} It gets 4 matches: A1,A2,A4,A5 But I need to modify this regular expression to get these 3 matches: A1,A2-A4,A5 Can anyone help me? 回答1: Just double the expression: [A-Z]{1,3}-?\d{1,3}(?:-[A-Z]{1,3}-?\d{1,3})? Demo 来源: https://stackoverflow.com/questions/29124643/how-to-include-character-in-regular-expression

Regex AND operator for overlapping matches

Deadly 提交于 2021-01-28 07:07:01
问题 I have two strings that are varying lengths of my name chriscattano christiancattano I have substrings in lengths of 3 through 10 that both strings share (chr)(hri)(ris)(cat)(att)(tta)(tan)(ano)(chri)(hris)(catt)(atta)(ttan)(tano)(chris)(catta)(attan)(ttano)(cattan)(attano)(cattano) I am trying to put these into a regex search that will successfully match the words chris and cattano so that I can do a .replace , and apply a <span> with a sass class to the match's results. If I format my regex

htaccess Rewrite Rules appending parameter?

巧了我就是萌 提交于 2021-01-28 07:05:04
问题 Our original urls began with a parameter and the following rewrite works to redirect them (thanks to Jon Lin). However, the original parameter is being appended to redirect, so that RewriteEngine On RewriteCond %{QUERY_STRING} ^old-page$ RewriteRule ^$ /newpage [R=301,L] ends up going to mydomain.com/newpage?old-page Any idea how to fix? thanks again, Geoff 回答1: Have it like this to strip off existing query string: RewriteEngine On RewriteCond %{QUERY_STRING} ^old-page$ [NC] RewriteRule ^$

stop requests for index.php+++++++++

眉间皱痕 提交于 2021-01-28 06:47:14
问题 I am trying to redirect users requesting a root index.php I was using Redirect 301 /index.php http://mywebsite/junk/index.html while this works ok IF people only request index.php, but now i am getting many requests for index.php++++ (sometimes more ++ than others) is there something I can add to Redirect 301 /index.php to include redirecting index.php+++ ? 回答1: You can use mod_rewrite for regex capabilities and finer control: RewriteEngine On RewriteRule ^index\.php http://mywebsite/junk

Translate this JavaScript Gibberish please? [closed]

∥☆過路亽.° 提交于 2021-01-28 06:32:10
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . I'm trying to modify and update an old Greasemonkey script with the goal of automatically adding an affiliate ID to all Amazon links. I'm a novice when

Remove characters between two characters

允我心安 提交于 2021-01-28 06:27:40
问题 I am having a problem with trying to remove text between two characters. I want to remove all text between = and , . Here is sample code I am trying to apply this to. "Y = Yellow, W = White, B = Blue, R = Black Out" What i want to do is have the above change to this. "Y W B R" or this but the above is prefered. "Y W B R = Black Out" Here is what i am trying. string input = "Y = Yellow, W = White, B = Blue, R = Black Out"; string regex = "(\\=.*\\,)"; string output = Regex.Replace(input, regex