Greetings, how do I perform the following in BSD sed?
sed 's/ /\n/g'
From the man-page it states that \n will be treated literally within a replacement string, how do I avoid this behavior? Is there an alternate?
I'm using Mac OS Snow Leopard, I may install fink to get GNU sed.
...
Hi, I am inexperienced with using C, and I need to use PCRE to get matches.
Here is a sample of my source code:
int test2()
{
const char *error;
int erroffset;
pcre *re;
int rc;
int i;
int ovector[OVECCOUNT];
char *regex = "From:([^@]+)@([^\r]+)";
...
Hi,
I want to use IntelliJ's find-and-replace feature to perform the following transformation:
// Replace this
model.put('foo', 'bar')
// With this
model['foo'] = bar
I've tried the following:
Text to find: model.put\((.*),(.*)\)
Replace with: model\[\\1\] = \\2
But Intellij doesn't seem to recognise \\1 and \\2 as backreferences. ...
Is there a regex that would validate a percentage value to 2 decimal places?
I have a regex for two decimal places, but don't know how to stop values above 100. e.g. 100.01 is validated with my regex.
...
This is a follow up to another question of mine. The solution I found worked great for every one of the test cases I threw at it, until a case showed up that eluded me the first time around.
My goal is to reformat improperly formatted tag attributes using regex (I know, probably not a fool-proof method as I'm finding out, but bear with...
I'm performing regex matching in .NET against strings that look like this:
1;#Lists/General Discussion/Waffles Win
2;#Lists/General Discussion/Waffles Win/2_.000
3;#Lists/General Discussion/Waffles Win/3_.000
I need to match the URL portion without the numbers at the end, so that I get this:
Lists/General Discussion/Waffles Win
T...
I would like to catch all "dev" tags and their respective content, through php preg_match_all() but can't get the nested ones.
data:
<dev>aaa</dev>
<dev>bbb</dev>
<dev>
ccc
<dev>ddd</dev>
</dev>
my expression so far:
|<dev>(.*)</dev>|Uis
thanks, for your help,
b.
...
I'm having an odd issue where, according to Javascript (in Chrome), all of the strings I tested match the Regex I have for a RewriteRule, but not all of them redirect properly.
My patterns are (in this order):
ups/sections/([A-Za-z]{3})/([A-Za-z0-9_+.-]+)$
ups/([A-Za-z_+.-]+)$
and the files I tested are:
(marked with + for a successf...
Example bad:
#main {
padding:0;
margin: 10px auto;
}
Example good:
#main {padding:0;margin:10px auto;}
I have a ton of CSS rules that are taking up too many lines. And I cannot figure out the :%s/ commands to use.
...
All,
I need to write a regular expression to perform the following operations
replace
(A)
src ="/folder/image.jpg"
or
src="http://www.mydomain.com/folder/image.jpg"
with
src="/cache/getCacheItem.aspx?source_url=http://www.mydomain.com/folder/image.jpg"
(B)
href="/folder/file.zip"
or
href="http://www.mydomain.com/folder/f...
My input string is:
"-->Job Title: Test text
JobId: 56565-116503
City: San Diego
State: CA
Zip Code: 92108
Description:
We are recruiting for a Controller to oversee all accounting and finance for a growing manufacturing company. We are looking for someone who is hands on full cycle accounting.
http://www.testurl.comhttp:...
I have a CSV-like text file that has about 1000 lines. Between each record in the file is a long series of dashes. The records generally end with a \n, but sometimes there is an extra \n before the end of the record. Simplified example:
"1x", "1y", "Hi there"
-------------------------------
"2x", "2y", "Hello - I'm lost"
---------------...
In C#, I'm trying to use regular expressions to replace values in a querystring. So, if I have:
http://www.url.com/page.aspx?id=1
I'd like to write a function where I pass in the url, the querystring value and the value to replace. Something along the lines of:
string url = "http://www.url.com/page.aspx?id=1";
string newURL = Replac...
Hello,
I'm looking for a way using jquery/javascript to get a class name when I only know part of it and there are more than one classes applied to that element.
So if I'm looking for a class that I know starts with "charLimit_" I want to know that full class name even when it's not the only class applied to a given element.
Example HTM...
I have a list of 400 strings that all end in "_GONOGO" or "_ALLOC". When the application starts up, I need to strip off the "_GONOGO" or "_ALLOC" from every one of these strings.
I tried this:
'string blah = Regex.Replace(string, "(_GONOGO|_ALLOC)", ""));'
but it is MUCH slower than a simple conditional statement like this:
if (strin...
Let's say I have some original text:
here is some text that has a substring that I'm interested in embedded in it.
I need the text to match a part of it, say: "has a substring".
However, the original text and the matching string may have whitespace differences. For example the match text might be:
has a
substring
or
has a s...
Is there a shell equivalent of PHP's preg_match?
I'm trying to extract the database name from this string in a shell script.
define('DB_NAME', 'somedb');
Using preg_match in PHP I could just do something like this.
preg_match('define(\'DB_NAME\','(.*)'\'\)',$matches);
echo $matches[1];
How can I accomplish the same thing in a she...
I have an .htaccess file that's using several rewrite rules. They don't seem to be working on a server I'm testing on, but they work on another server. I tested using a rule that doesn't use a regex, and that seems to work. Is there any way that regex rules can be disabled (or enabled) in Apache?
...
var_dump(preg_match_all('/(job_show\.asp\?id=[0-9]*)">/s',':</font><a href="job_show.asp?id=42"',$match));
$hrefs = $match[1];
var_dump($hrefs);
Output is:
int(0)
array(0) {
}
It's supposed to match "job_show.asp?id=42"
...
I've got the following string:
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")]
I need to alter it to look like the following:
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("myClass", "myVersion")]
The simplest way to achieve this, obviously, is to use a Regex...