string-manipulation

JavaScript String Replace with a tricky regular expression

Hi. I'm trying to work out what regular expression I would need to change this string html = '<img style="width: 311px; height: 376px;" alt="test" src="/img/1268749322.jpg" />'; to this html = '<img width="311" height="376" alt="test" src="/img/1268749322.jpg" />'; with the help of Javascript.replace. This is my start: html = ht...

String chunking algorithm with natural language context

I have a arbitrarily large string of text from the user that needs to be split into 10k chunks (potentially adjustable value) and sent off to another system for processing. Chunks cannot be longer than 10k (or other arbitrary value) Text should be broken with natural language context in mind split on punctuation when possible split ...

Working with PHP Octals and String conversions

I'm working with a database that has a bunch of serial numbers that are prefixed with leading 0's. So a serial number can look like 00032432 or 56332432. Problem is with PHP I don't understand how the conversion system with octals works. A specific example is that I'm trying to convert and compare all of these integer based numbers...

c++ creating ambigram from string

I have a task to implement "void makeAmbigram(char*)" that will print on screen ambigram of latin string or return something like 'ambigram not possible'. Guess it's just about checking if string contains only of SNOXZHI and printing string backwards. Or am I wrong ? I'm a complete noob when dealing with cpp so that's what I've created ...

Escaping an equals sign in DOS batch string replacement command

I need to replace some text in a JNLP file using a DOS batch file to tune it for the local machine. The problem is that the search pattern contains an equals sign which is messing up the string replacement in the batch file. I want to replace the line, <j2se version="1.5" initial-heap-size="100M" max-heap-size="100M"/> with specific...

How to remove the file extension in a zsh completion?

I want to adjust zsh so that I can tab complete: myprog <tab> using all *.foo files in ~/somedir, but have it so that it displays them without the .foo extension. Is there any way to do this? This is what I have so far: #compdef myprog typeset -A opt_args local context state line local -a mydirs mydirs="(. ~/somedir)" _arguments -...

Replace in place, parsing & string manipulation.

I'm trying to replace a set of characters within a string. The string may or may not have any data to change. The string is marked up in a way that allows for it to change it's color from a set of characters. The string can reset it's formatting to default by using a defined set of characters. This setup is very much like the ECMA-48 st...

"Simple" Text replace function

I have a string which is basically a list of "words" delimited by commas. These "words" can be pretty much any character e.g. "Bart Simpson, Ex-girlfriend, dude, radical" I'm trying to use javascript, jQuery, whatever i can to replace a word based on a search string with nothing (in essence, removing the word from the list). For exampl...

jQuery trim function does not work in IE7?

I'm trying to call the jQuery text() function and run it through the trim() function to remove all trailing and leading whitespace. Seems to work great in Firefox, however, does not work in IE7 (refuses to remove a space trailing at the end). Any ideas?! Maybe a regex solution? ...

Check if a string contains a substring in SQL Server 2005 Stored Procedure

Hello I've a string @mainString = 'CATCH ME IF YOU CAN'. I want to check whether the word 'ME' inside @mainString. So how to check if a string has a substring in sql? Thank you Regards NLV ...

Can't separate string using sscanf?

Hi, I have a text file of associated numbers i.e; 1 2 2 3 2 1 3 4 3 Each line is a seperate piece of information, as such I am trying to read it in one line at a time and then seperate it into the 3 numbers but sscanf isn't doing what I expect it to. char s[5]; char e[5]; char line[100]; int d; fgets(line, sizeof(line), inFile); ssc...

In Javascript is there a function that returns the number of times that a given string occurs?

In Javascript is there a function that returns the number of times that a given string occurs? I need to return a numeric value that is equal to the number of times that a given string occurs within a particular string for instance: var myString = "This is a test text" If I had to search for 'te' in the above string it would return 2....

strcasecmp in C returns 156 instead of 0, any ideas why?

I have the following code: printf("num: %d\n", strcasecmp(buf, "h\n")); And I get the following results when I try plugging in different letters: a: -7 g: -1 i: 1 j: 2 h: 156 H: 156 Should strcasecmp not return 0 when buf is equal to H or h? Any ideas why it's returning 156? I need to figure out how to check whether the user types ...

Loop over a file and write the next line if a condition is met

Having a hard time fixing this or finding any good hints about it. I'm trying to loop over one file, modify each line slightly, and then loop over a different file. If the line in the second file starts with the line from the first then the following line in the second file should be written to a third file. with open('ids.txt', 'rU') ...

BASH statements execute alone but return "no such file" in for loop.

Another one I can't find an answer for, and it feels like I've gone mad. I have a BASH script using a for loop to run a complex command (many protein sequence alignments) on a lot of files (~5000). The loop produces statements that will execute when given alone (i.e. copy-pasted from the error message to the command prompt), but which r...

Convert From Custom List to List of String

Hi all I have the following code: Public Shared Function ConvertToString(ByVal list As IList) As String Dim strBuilder = New System.Text.StringBuilder() Dim item As Object For Each item In list strBuilder.Append(obj.ToString()) strBuilder.Append(",") Next Return strBuil...

Regex: replace inner string

I'm working with X12 EDI Files (Specifically 835s for those of you in Health Care), and I have a particular vendor who's using a non-HIPAA compliant version (3090, I think). The problem is that in a particular segment (PLB- again, for those who care) they're sending a code which is no longer supported by the HIPAA Standard. I need to l...

Formatting a date string when the string sits inside another string

Hi, I'm trying to figure out a way to format a date string that sits inside string using javascript. The string can be: "hello there From 2010-03-04 00:00:00.0 to 2010-03-31 00:00:00.0" or "stuff like 2010-03-04 20:00:00.0 and 2010-03-31 00:00:02.0 blah blah" I'd like it to end up like: "stuff like 4 March 2010 and 31 March 2010 ...

String parsing help

I have a string like the following: $string = " <paragraph>apples are red...</paragraph> <paragraph>john is a boy..</paragraph> <paragraph>this is dummy text......</paragraph> "; I would like to split this string into an array contanining the text found between the <paragraph></paragraph> tags. E.g something like this: $string = " <p...

Is there a way to prevent a string of letters with no spaces from overflowing out of its corresponding boundaries?

The question is pretty straight forward, I have tried using a span with rules set to clear:both; and display:block;, at the bottom of each list entry where the text is being inserted in with no luck. I am not really sure what to do on this. I don't expect to many entries with long consecutive letter strings but for example if someone doe...