|
I’m selecting data on an old database which has an abused status column. The status column has multiple pieces of information in it. Values are like ‘New Contact YYYY’, ‘Online YYYY’, ‘Updated YYYY’, ‘Withdrawn YYYY’, etc…. As you may have guessed, YYYY...
Started by John MacIntyre on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If you simply want to extract a four digit year from the string, you could use PATINDEX
SELECT SUBSTRING(FieldName, PATINDEX('%[0-9][0-9][0-9][0-9]%', FieldName), 4) FROM TableName
If the year allways are the last 4:
SELECT right(FieldName,4) from table... .
|
|
I'm tring to run a find and replace query on some sql data using Management Studio. I basically want to remove the word FREE from any content.
I tried running this query;
UPDATE Table_1 SET ContentDetails = REPLACE(ContentDetails, 'FREE', '') WHERE (ContentDetails...
Started by Neil Bradley on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Try
UPDATE Table_1 SET ContentDetails = REPLACE(CAST(ContentDetails as VARCHAR), 'FREE', '') WHERE (ContentDetails LIKE '%FREE%')
although it might cut the data off where the value is longer than field as a varchar with the length of the....
|
|
There are heaps of Qs about this on this forum and on the web in general. But I don't just get it.
Here is my code:
function updateGuideKeywords($dal) { $pattern = "/[^a-zA-Z-êàé]/"; $keywords = preg_replace($pattern, '', $_POST['keywords']); echo json...
Started by Steven on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
This may not be 100% accurate, but looking at the regex your using i don't think preg_replace literal matches, but in situations like a character class you're now matching two bytes separately "match anything that's not English letter, minus....
|
Ask your Facebook Friends
|
In AS3 you have a function on a string with this signature:
function replace(pattern:*, repl:Object):String
The repl:Object can also specify a function. If you specify a function, the string returned by the function is inserted in place of the matching...
Started by Lieven Cardoen on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Static void Main() { string s1 = Regex.Replace("abcdefghik", "e", match => "*I'm a callback*"); string s2 = Regex.Replace("abcdefghik", "c", Callback... .
In order to do this in C#, use System.Text.RegularExpressions.Regex.Replace() which takes a callback .
|
|
Yes, this is a really lazy question but I figure this is problem that people have often enough that someone here would have something already written to share.
I have a ton of C files with #include statements using Windows relative paths. I'm working ...
Started by pr1001 on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
You should have bash/awk/sed in OS X
for cfile in *.c do awk '/#include/{gsub(/\\/,"/")}1' cfile >temp mv temp cfile... .
Sed '/^[ ]*#[ ]*include/ s:\\:/:g'
This should be pretty robust as it should catch any legal format of #include but not anything else .
|
|
I have a server written in Java that runs as a Windows service (thanks to Install4J). I want this service to be able to download the latest version of the JAR file it runs from, and start running the new code. The stitch is that I don't want the Windows...
Started by Alex on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
The docs state
The subprocess ....
I suppose you could work around it by using the Java Runtime.exec or ProcessBuilder 's start() command (which start new processes) then letting the current one end.. .
As far as I know, there is no way to do this in Java .
|
|
Okay, here's what I'm trying to do: I'm trying to use PHP to develop what's essentially a tiny subset of a markdown implementation, not worth using a full markdown class.
I need essentially do a str_replace, but alternate the replace string for every ...
Started by redwall_hp on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Personally, I'd loop through each occurrence of * or \ with a counter, and replace the character an asterisk, replace it with <em> , if it's odd then replace it with </em> , etc for each might be the easiest solution.
|
|
I came to know PHP after Perl, so when I first found preg_* function I basically just used those. Later I read that str_replace() is faster when dealing with literal text. So my question is, can't preg_replace() be as efficient as str_replace() when the...
Started by kemp on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Although trying to do the same in preg with str_replace, is actually slower....
If you've got blanks that can be matched by a pattern, use preg otherwise attempt with str_replace.
Is for like changing words (like a word filter).
|
|
I have some text, something like this:
Paragraphs of text (SOME KNOWN TEXT)Unknown Text(SOME OTHER KNOWN TEXT) Some additional paragraphs of text
What I want is to keep the Unknown Text , but get rid of the ( SOME KNOWN TEXT) and (SOME OTHER KNOWN TEXT...
Started by OneNerd on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Something like this:
$new_text = preg_replaceIf the two texts truly are known, you can do this:
$result = str_replace(array('(SOME KNOWN TEXT is better performance than a regular expression....
Of these, you're probably better off using a regex.
|
|
I use PHP.
I'm working on a way to automatically put together all my CSS files into one. I automatically load the CSS-files and then saves them to a larger one, for upload.
In my local installation I have some @import lines that needs to be removed.
It...
Started by Jens Törnell on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Str_replace("@import", '', $str);
You could easily iterate over each line and then determine to find the @imports using preg_match, then replace them using str_replace
$str = "<<css data>]; $text = file_get_contents($url)....
|