Regular expressions are a declarative language, mainly used for pattern matching within strings. Please include a tag specifying the programming language you are using, together with this tag.
2
votes
1answer
70 views
Regular expression for application version
Only these formats are accepted.
1.1.1
1.1.1-r
1.1.1-b
1.1.1-r1
1.1.1-b1
I wrote this code. What don't I like in it? I used parentheses and now I have two groups. In fact, I don't need to do ...
0
votes
1answer
57 views
Improvment of and looping in a regular expression pattern
My implemented regex pattern contains two repeating symbols: \d{2}\. and <p>(.*)</p>. I want to get rid of this repetition and asked myself if there is a way to loop in Python's regular ...
1
vote
1answer
95 views
Faster JavaScript fuzzy string matching function?
I'm using the following function to fuzzy match strings:
function fuzzy_match(str,pattern){
pattern = pattern.split("").reduce(function(a,b){ return a+".*"+b; });
return (new ...
1
vote
2answers
66 views
php most efficient way to check if a variable contains only certain chars
I have a small function which I regularly use to check if a variable contains only [a-z][0-9] and the special chars '-' and '_'. Currently I'm using the following:
function is_clean($string){
...
1
vote
1answer
18 views
To extract specific information in the stack trace using regular expression
I encountered a problem at http://regexone.com/example/6?
You can view the problem by clicking the link.
There was required a regular expression to extract the method name, filename and the line ...
1
vote
3answers
97 views
How should I read coordinates from a text file?
I have a text file with lines that look like this:
Robot(479.30432416307934|98.90610653676828)
Robot(186.42081184420528|213.11277688981409)
Robot(86.80794277768825|412.1359734884495)
or, more ...
-4
votes
1answer
25 views
Regex to change uri file name [closed]
Looking for regex to change file name in uri to allow linking to answer sheet from question bank.
...
2
votes
1answer
29 views
Encapsulate results in div tags
I would like to turn the following:
<div>this is a $test</div>
into
<div>this is a <div>$test</div></div>
currently I have
var regexp = new ...
1
vote
2answers
38 views
How to make this Regex more flexible?
I am creating a simple template engine that uses Regex to find special expressions, which are parsed and processed. They are enclosed in Ruby-style opening tags and have the format:
<% label ...
0
votes
0answers
44 views
Python pattern searching using re standard lib, str.find()
I'm trying to improve some code in order to get a better perfomance, I have to do a lot of pattern matching for little tags on medium large strings, for example:
import re
STR = ...
1
vote
3answers
176 views
Regex to get all image links - is this efficient?
I have some pretty basic Regex that scans the output of a HTML file (the whole document source) and attempts to extract all of the absolute links that look like images. Whether they are actually ...
3
votes
1answer
178 views
How/where can I improve this code?
I'm quite new to Javascript, what areas of the code should I concentrate on improving, and if possible, how to improve them.
Basically, the code looks for certain emoticon characters (like :) or :|) ...
3
votes
1answer
63 views
Count comments and lines of code in ruby
Hi I wrote a small script as an answer for a stack overflow question, that counts lines of code and comments (in C and C++ style).
f = File.open("test.txt")
loc = 0
comments = 0
while line = f.gets
...
4
votes
2answers
91 views
Refactor highlight matched word in string
I have following method which highlight matched word in text:
# Hightlight matched term
#
# Ex(for term: some):
# "<span class="bold">Some</span> CEO Event"
#
def ...
1
vote
2answers
60 views
Http url validating
What do you think about this?
#utils.py
def is_http_url(s):
"""
Returns true if s is valid http url, else false
Arguments:
- `s`:
"""
if ...