Regular and Irregular Expressions Regular expressions are a powerful form of declarative programming language, mainly used for pattern matching within strings. Students of computer science know them as the user-friendly face to the abstruse field of finite automata. The rest of us think of them as ...
1
vote
1answer
67 views
Pirate Bay name and magnet mailer
So, first time I try PHP. Thought I'd set a goal for myself, divide it up in smaller problems and start googling. So yes I got it to work, very happy.
But, it is rather crude and ugly. So now I would ...
3
votes
0answers
56 views
Unicode parsing in PHP
Firstly, apologies if this is not the correct type of question for here, I had it on the stackoverflow but it was closed with a suggestion I post here.
I’m in the process of converting from Latin 15 ...
2
votes
2answers
65 views
Add getters and setters to a set of variables
Any improvements are welcome.
a.bat
sed -r "s/private (.*) (.*);(.*)/&\npublic \1 get\u\2(){return \2;}\npublic void set\u\2(\u\2){this.\2=\u\2;}\n/" "%~1">"%~2"
in:
private String ...
2
votes
2answers
111 views
Better implementation of a simplified regular expression engine?
Task:
On an alphabet set [a-z], a simplified regular expression is much simpler than the normal regular expression.
It has only two meta characters: '.' and '*'.
'.' -- exact one arbitrary ...
2
votes
1answer
66 views
I'm trying to escape some xml to be used with SOAP
I'm attempting to escape ampersands from a string before passing to PHPs SimpleXMLElement->addChild() for use with some soap webservices, but I don't want to double escape them. I'm getting these ...
2
votes
2answers
53 views
Bulleted list from dashes
Let's keep this simple.
Input:
- abc
- def
- ghi
Desired output (whitespace optional):
<ul>
<li>abc</li>
<li>def</li>
<li>ghi</li>
...
2
votes
2answers
87 views
Replace match inside tags
The problem I want to solve is to replace a given string inside tags.
For example, if I'm given:
Some text abc [tag]some text abc, more text abc[/tag] still some more text
I want to replace abc ...
3
votes
1answer
135 views
Simplify regular expression? (Converting Unicode fractions to TeX)
Background
I'm converting Unicode text to TeX for typesetting. In the input, I'm allowing simple fractions like ½ and ⅔ using single Unicode characters and complex fractions like ¹²³/₄₅₆ using ...
0
votes
1answer
113 views
Python program for converting scientific notation to fixed point
I had to replace all instances of scientific notation with fixed point, and wrote a Python script to help out. Here it is:
#!/usr/bin/python2
# Originally written by Anton Golov on 29 Jan 2012.
# ...
4
votes
3answers
123 views
How to determine the order of letters by regex?
I want to write a regular expression to determine whether a given string is uppercase and sorted in non-descending order.
^A*B*C*D*E*F*G*H*I*J*K*L*M*N*O*P*Q*R*S*T*U*V*Q*X*Y*Z*$
I was just wondering ...
0
votes
0answers
109 views
Regex to match dates effectively [closed]
Here is the code I got from a random Google search; there is one date on that page. This regex is suppose to match every date format, but isn't getting anything. Can someone help me tweak the ...
4
votes
3answers
205 views
Checking a HTML element's class
$('pre').each(function(index) {
var c = $(this).attr("class");
if (!c) {
return true;
}
// Match only Javascript code snippets
if (!c.match(/brush: js; class-name: ...
0
votes
1answer
93 views
Help me optimize this code using Regular Expressions in C#
I have a requirement to capture string in a specific format of * [Numeric Digits] *. This is how I have done right now but I think it would be faster with Regular Expressions. I dont have a lot of ...
2
votes
2answers
129 views
Code Improvement: Copy Regex named capture groups to strongly typed object
This code works to copy named capture groups of a Regex to the same named properties of a strongly typed object. However, it's not pretty. Someone mentioned I should use polymorphism to at least ...
2
votes
1answer
74 views
filter out password in xml string
We're storing the xml communications with an external service in a text in the db and in a before_create I've got the following:
# filter opera password
def remove_password!
...