Skip to content
Fix Code Error

Tag: regex

Regex problem: find if error stack has “anonymous” with line and column

July 17, 2021 by Code Error

Posted By: Anonymous Imagine there is the JavaScript error like: ReferenceError: f is not definedn at eval (eval at CodeR._this.javascriptRun (http://127.0.0.1:5000/static/dist/a.bundle.js:29635:20), <anonymous>:4:2)n at CodeR._this.javascriptRun (http://127.0.0.1:5000/static/dist/a.bundle.js:29635:20)n at http://127.0.0.1:5000/static/dist/a.bundle.js:29554:15n at new Promise (<anonymous>)n at CodeR._this.evaluateCode (http://127.0.0.1:5000/static/dist/a.bundle.js:29553:25)n at callCallback (http://127.0.0.1:5000/static/dist/a.bundle.js:102449:12)n at commitUpdateEffects (http://127.0.0.1:5000/static/dist/a.bundle.js:102487:7)n at commitUpdateQueue (http://127.0.0.1:5000/static/dist/a.bundle.js:102475:3)n at commitLifeCycles (http://127.0.0.1:5000/static/dist/a.bundle.js:110741:11)n at commitLayoutEffects (http://127.0.0.1:5000/static/dist/a.bundle.js:113941:7) How to check it and if …

Continue Reading

Too many redirects – redirecting IE to a specific page with htaccess

July 17, 2021 by Code Error

Posted By: Anonymous I’m trying to redirect IE-user to a specific page by using htaccess. This is what I got so far: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_USER_AGENT} ^.*Trident.*$ RewriteRule (.*) /not-supported-browser.html [R=301,L] </IfModule> But whenever I’m requesting some page with IE11, I’ll get the error "too many redirects". I changed my condition to Firefox …

Continue Reading

How to find bs4 XML attribute values with BeautifulSoup by identifying attribute by regex in any XML depth?

July 17, 2021 by Code Error

Posted By: Anonymous I have the following bs4 element: from bs4 import BeautifulSoup html_doc = """ <l2 attribute2="Output"><s3><Cell cell_value2="384.01"/></s3></l2>, <l1><s3 attribute1="Cost"><s4><Cell cell_value1="2314.37"/></s4></s3></l1> """ soup = BeautifulSoup(html_doc, "html.parser") I want to extract all the attribute values like this: ["Output", "Cost"] My question is: How can I achieve this with regex re.compile(r’^attribute[0-9]$’) and in a situation where …

Continue Reading

Regular Expression to match only all non-hidden graphic files

July 16, 2021 by Code Error

Posted By: Anonymous I am writing a regular expression that should match all(or most) of the graphic files (non-hidden) So I came up with the following expression ^[^.][A-Za-z0-9]+(.(gif|jpeg|jpg|pdf|png|tiff|tif|psd|eps|bmp))$ I am not sure how to include other characters in the [A-Z…..] bracket so that anything, like "-" or "_" would be included. Solution You can just …

Continue Reading

Regex value is converted into an empty object after sending it in the request body. Why is it happening and what are the other ways to solve this?

July 15, 2021 by Code Error

Posted By: Anonymous I am using Node.js and I need to pass the following filter object in the request body: const filter = { ‘userName’: { ‘$regex’: /^Test$/i }, ‘userCode’: ‘0071’ } I used axios to call userMicroservice API and added the filter I created in the request body: const { data } = await …

Continue Reading

no matching function for call to ‘regex_match’

July 14, 2021 by Code Error

Posted By: Anonymous Can anyone tell me why function regex_match is not working. It is always giving error saying [cquery] no matching function for call to ‘regex_match’. I am familiar with regex library of python but I was trying whether this works for cpp. #include <iostream> #include <string> #include <regex> using namespace std; int main …

Continue Reading

non-capturing group still shows?

July 14, 2021 by Code Error

Posted By: Anonymous I am trying to get the string starting from third / in a url. here is the url: http://192.168.1.253:18888/2021/03/11/896459e4-875f-455a-a2cb-768c879555e7.png I wish to get /2021/03/11/896459e4-875f-455a-a2cb-768c879555e7.png So I used the following regex (?://.+)/.+ ?: marks a non-capturing group, so //192.168.1.253:18888 shouldn’t be matched. But when I test in regex101.com, its result is //192.168.1.254:18888/2021/03/11/896459e4-875f-455a-a2cb-768c879555e7.png. Why …

Continue Reading

How to match string between two words, and repeat this pattern for all two defined words in the string, Regex?

July 13, 2021 by Code Error

Posted By: Anonymous So I want to extract MathML from HTML. For example, I have this string: <p>Task:&nbsp;</p><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>5</mn></mrow></math><p>&nbsp;find&nbsp;</p><math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi>x</mi><mn>2</mn></msup></math><p>.</p> I want to match <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>5</mn></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi>x</mi><mn>2</mn></msup></math> How can I achieve this. I’ve tried this expression /(<math)(.*)(math>)/g but it matches everything between first <math and last math> words. Solution By default, the quantifiers …

Continue Reading

Split string on “$” using regex

July 13, 2021 by Code Error

Posted By: Anonymous I am trying to split a string using regex on $ symbol but the output is not what I want. string = "43$hello" list_of_splits = re.split("$",string) Output: [’43$hello’,”] Output I want: [’43’,’hello’] It’s visible by the output that "$" is a special character in regex, but now by how can I do …

Continue Reading

non-greedy regex capture groups syntax

July 12, 2021 by Code Error

Posted By: Anonymous given the following text key: foo/bar:v1.2.3 key: baz/spam:1.2.3 greedy i have tried the following regex: ^s*key: (?<ref>.*?):(?<ver>.*) which returns the following groups (demo): ref: foo/bar, ver: v1.2.3 ref: baz/spam, ver: 1.2.3 greedy what is missing from the regex in order to matchgroup the version (e.g. 1.2.3) without the preceding text (e.g. greedy)? …

Continue Reading

Regex to interpret smtlib2 format

July 11, 2021 by Code Error

Posted By: Anonymous I am trying to figure out a regex that could match results of a program that outputs in the smtlib format. Basically, my data is in the form: (define-fun X_1 () Int 281) (define-fun X_71 () Int 104) (define-fun X_90 () Int 21) (define-fun X_54 () Int 250) etc. Is it possible …

Continue Reading

Novice regex issue determining if executable in os

July 10, 2021 by Code Error

Posted By: Anonymous I’m having issues matching the "yes" string portion of this output (if the executable is not there i’d assume it says "no" but maybe there’s a better cross-platform solution?): checking for docker-compose… yes Here’s my code I wrote: require ‘mkmf’ logs = find_executable ‘docker-compose’ if logs.match(/yes/) puts "hi" else puts "bye" end …

Continue Reading

Regex that matches newlines literally and passively

July 9, 2021 by Code Error

Posted By: Anonymous I have to construct a regex that matches client codes that look like: ✘✘✘/X{3,6} ✘✘✘.X{3,6} ✘✘✘.X{3,6}/✘✘✘ With X a number between 0 and 9. The regex needs to be strong enough so we don’t extract codes that are within another string. The use of word boundaries was my first idea. The regex …

Continue Reading

Regex: Ignore order of capture groups and capture only last occurrence

July 9, 2021 by Code Error

Posted By: Anonymous Let’s say we have the following string: 1|order=asc|type=1 We need to create regex that will parse it to parameters assuming that string always should start with number and will (optionally) have parameters (order, asc) in any order. Also it may have 3 and more parameters but let’s keep 2 here for simplicity. …

Continue Reading

How to get all regex matches from substrings only with regex

July 9, 2021 by Code Error

Posted By: Anonymous I’m trying to get all hex colors from styles attributes in html, but not another hex color values. Really it is a common task I want to understand so I don’t want to get other solution, regex only. In other words I need to get substrings with a regex pattern (hex color …

Continue Reading

Regex Pattern Starting from X Pattern until X Pattern

July 9, 2021 by Code Error

Posted By: Anonymous I have been trying to figure out the regex expression but keep failing. I need to be able to group the text file starting with the 5 digit number sequence until the next 5 digit number sequence from the data below a group would be considered the following: 000001 10_SEC_SLATE_-_ACT_1.NEW.02 V C …

Continue Reading

Lookbehind with “not character” ignores match at position 0

July 9, 2021 by Code Error

Posted By: Anonymous I am trying to achieve a regex to select (%?[fFsmhd]){1,} preceded by + and not by +. My first option was (?<=[^\]+)(%?[fFsmhd]){1,} which seems to work except that the position 1 is never matched. Test: +fFsmhd (problem here, does not match) +fFsmhd (matches) A workaround I found to this problem is to …

Continue Reading

Elasticsearch regex to find phone number and email

July 9, 2021 by Code Error

Posted By: Anonymous I tried using a query to search for all those which are like phone numbers or/and email within elasticsearch. Unfortunately, I can’t find correct syntax for it. { "query": { "regexp": { "biography": { "value": PHONE_NUMBER_REGEXP || EMAIL_REGEX # <– problem is here } } } } Maybe somebody has a solution. …

Continue Reading

Regex for finding series of characters in the middle of string based on surrounding characters

July 8, 2021 by Code Error

Posted By: Anonymous I’m trying to use regex to extract codes from some strings. The position of the part I want to extract is not consistent but it does follow a pattern: It always follows the last forward slash and always ends before the first underscore. I’ve made bold the part I hope to extract …

Continue Reading

sre_constants.error: nothing to repeat in jython

July 8, 2021 by Code Error

Posted By: Anonymous I have html content I want to get comment from this content content = """<html> <body> <!–<h1>test</h1>–> <!–<div> <img src=’x’> </div>–> Blockquote <!– <div> <img src=’xe’> </div> –> </body> </html>""" i use this regex regex_str = "<!–((n|r)+)?((.*?)+((n|r)+)?)+–>" When running this line in Python re.findall(regex_str,content) It works successfully but when running in jython …

Continue Reading

Group adjacent regex matches

July 8, 2021 by Code Error

Posted By: Anonymous I am trying to build a regex that finds the number of syllables in a word with the following conditions: Vowels are counted as syllables. Two or more consecutive vowels are counted as one syllable Ignore ‘e’ if it is the last letter in a word (don’t count it as a syllable) …

Continue Reading

regex.test() keep returning false when test with string from FileSystem.readAsStringAsync

July 8, 2021 by Code Error

Posted By: Anonymous I’m trying to use regex to test the string. The string is read from a text file. When I test the string directly read from the text file, the regex.test() keep returning false. But when I copy the content of the text file and save it in the variable manually, the regex.test() …

Continue Reading

Regex: /(w)(w*)(s|$)/g, “$2$1ay$3”

July 7, 2021 by Code Error

Posted By: Anonymous I am trying to understand how below regex pattern works, could someone please help, I know what it does, it will add "ay" at the end every word after moving first char of each word to the end of the word. But I dont how this below regex is doing it. /(w)(w*)(s|$)/g, …

Continue Reading

Rewrite regexp in nginx

July 7, 2021 by Code Error

Posted By: Anonymous This is the nginx config: location @rewrite { rewrite ^/threads/ /thread.php?$uri&$args last; } That code works fine, but I want to use another route now. OLD: /threads/123-yyy-yyy-yyy NEW: /✘✘✘-✘✘✘-✘✘✘/123-yyy-yyy-yyy I’ve tried some like: rewrite ^/[w]+/([d]+-[w]+)?$ /thread.php?$1&$args last; rewrite ^/[w]+/([d]+-[w]+)?$ /thread.php?$1&$args last; rewrite ^/w+/(d+-w+)?$ /thread.php?$1&$args last; rewrite ^/w+/(d+-w+)$ /thread.php?$1&$args last; But the page …

Continue Reading

Mongoose: search for users with certain regex query

July 6, 2021 by Code Error

Posted By: Anonymous I have a mongoose query that searches for users that match a certain regex let { q } = req.query; // prettier-ignore q = q.replace(".", ‘.’); // find user const users = await db.User.find({ email: new RegExp(`${q}`, "ig"), }); I am trying to match the exact character < . > DOT but …

Continue Reading

grepl in R returns FALSE when string contains substring

July 6, 2021 by Code Error

Posted By: Anonymous I’m trying to check if a string is not a substring of another in R: str = "85925108, 85940105, 85940105, 85940157" val = "85940157" if(!grepl(str, val, fixed=TRUE)){ … } The if statement ends up running, which means grepl is returning FALSE. I checked some other Stack Overflow answers and the grepl documentation, …

Continue Reading

how to return true if you have entered any of the letter between specified word (in my case it is ‘active’) using regex or any other way in node.js

July 6, 2021 by Code Error

Posted By: Anonymous hello guys I want return value as 1 if user entered the letters between ‘active’ using node.js. currently I am using multiple if statement but I want simple and short code, how can I solve this using regex? or any other way? currently I am using bellow code but I want minimal …

Continue Reading

Regex to remove all characters after variable length number + comma + 17 characters

July 6, 2021 by Code Error

Posted By: Anonymous Each line of my file is formatted as follows: NumberOfAnyLength,17Characters,UnneededText I would like to retain only the following for each line: NumberOfAnyLength,17Characters In other words, I would like to remove the second comma and everything after it. I am trying to do this with a regex in Notepad++ via Replace. Any help …

Continue Reading

Python regex with named group in conditional expression

July 6, 2021 by Code Error

Posted By: Anonymous I’m having trouble getting a regex to work using a named group and a conditional expression. I’ve simplified the problem to the smallest possible example. The regex r"(?P<x>d)(?(x)a|b)" would seem to mean "match a digit, and if you matched a digit (named group x) also match an a, but if not, match …

Continue Reading

JTable RowFilter – case insensitive

July 6, 2021 by Code Error

Posted By: Anonymous I’m having a problem with a RowFilter, I’m trying to make it display data without it being case sensitive. DefaultTableModel table=(DefaultTableModel)tablicaEv.getModel(); String search=jTextField1.getText(); TableRowSorter<DefaultTableModel> tr=new TableRowSorter<> (table); tablicaEv.setRowSorter(tr); tr.setRowFilter(RowFilter.regexFilter(search); I tried adding "(?!)" in the RegexFilter but that only makes my table not display any data at all when I try searching. …

Continue Reading

Posts navigation

  • 1
  • 2
  • 3
  • 4
  • …
  • 27
  • Next

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error