string-manipulation

PHP update url in variable

$link = http://site.com/view/page.php?id=50&amp;reviews=show How can we add &extra=video after id=50? id is always numeric. url can have many other variables after ?id=50 &extra=video should be added before the first & and after the 50 (value of id) It will be used this way: echo '<a href="' . $link . '">Get video</a>'; Thanks. ...

Copy substring of one column and copy to another.

This is a bit above my level. But am trying to learn. I don't want to seem like I'm just trying to get my homework done but would appreciate any help pointers. I am trying to find a substring (postcode) in an address column and once found, copy to the post code column I have the following sql which finds columns that match a postcode pa...

String manipulation

Given an input string, I would like to get the output from this in the specified format: filename;path. For the input string /vob/TEST/.@@/main/ch_vobsweb/1/VOBSWeb/main/ch_vobsweb/4/VobsWebUI/main/ch_vobsweb/2/VaultWeb/main/ch_vobsweb/2/func.js I expect this output string: func.js;VOBSWeb/VosWebUI/VaultWeb/func.js The filename is lis...

append or + operator in StringBuffer?

In my project there are some code snippets which uses StringBuffer objects, and the small part of it is as follows StringBuffer str = new StringBuffer(); str.append("new " + "String()"); so i was confused with the use of append method and the + operator. ie the following code could be written as str.append("new ").append("String()...

java evaluate string to math expression

I am trying to write a java routine where i can evaluate simple math expression from String for example: "5+3" or "10-40" or "10*3" i want to avoid a lot of if then else. any pointer will be helpful - S ...

C# - why is \n\r not working?

In a database field, I'm returning I'm storing the "body" of my email (in case it changes). In this I have \n\r characters to get new lines. But, it seems not to be working. Any thoughts: So data in field: 'TBD.\r\n\nExpect' And my output looks like that TBD.\r\n\nExpect Thoughts? ...

How to manipulate and validate string containing conditions that will be evaluated by php.

Part of the program I am creating consists of the user creating conditions which I will store in a mysql database. I want the syntax to be somewhat easier than what php allows but since this will ultimately be run as php code using eval() it needs to have valid syntax. For example: User Input: 4<var1<=9 AND var2<6 Result should be: ...

Is there a way to get the Nth index of a specified char in T-SQL? (Without Substring!)

Hello, I am trying to get the index of the Nth character inside a varchar(MAX). Right now I am cutting off the front end of the varchar so I only have to check for the first but With extremely large varchars the process is getting way too slow. I would like to parse through the varchar(max) and just keep track of what index I am at and g...

Reading String from File with Objective C

This one is weird. Hopefully I will ask the right question: I'm using an md5 method to create a checksum value which I then write to a file. Then afterwards I read the file using this: NSString * id_From_File = [[NSString alloc] initWithContentsOfFile:path_to_ID encodi...

Debug Assertion Error - delete call on char pointer

So I decided to dwelve a bit within the pesty C++. When I call the delete function on a pointer to a simple class that I created I'm greeted by a Debug Assertion Failure -Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse). I assume this is because I've handled the string manipulation wrong and thus causing memory corruption. I created ...

String Algorithm Question - Word Beginnings

Hi guys. I have a problem, and I'm not too sure how to solve it without going down the route of inefficiency. Say I have a list of words: Apple Ape Arc Abraid Bridge Braide Bray Boolean What I want to do is process this list and get what each word starts with up to a certain depth, e.g. a - Apple, Ape, Arc, Abraid ab - Abraid ar -...

C string interpolation

I'm building simple http status checker in C. I've got the network part done, but I'm having trouble with string manipulation. Here how it works: $ ./client http://domain.com/path.html#anchor 200 This utility simply outputs the status of given page on the command line. I need to parse the given string into hostname and request path. I...

Multi-split in Python

How would I split a string by two opposing values? For example ( and ) are the "deliminators" and I have the following string: Wouldn't it be (most) beneficial to have (at least) some idea? I need the following output (as an array) ["Wouldn't it be ", "most", " beneficial to have ", "at least", " some idea?"] ...

c# - How to produce string with 'and' in the correct place.

Here is the loop I have so far foreach (CheckBox chk in gpbSchedule.Controls.OfType<CheckBox>()) { if (chk.Checked) { //Code goes here } } The checkboxes all have text values of the days of the week. Monday, Tuesday ect....

Using .NET RegEx to retrieve part of a string after the second '-'.

Hey guys, This is my first stack message. Hope you can help. I have several strings i need to break up for use later. Here are a couple of examples of what i mean.... fred-064528-NEEDED frederic-84728957-NEEDED sam-028-NEEDED As you can see above the string lengths vary greatly so regex i believe is the only way to achieve what ...

separate string in two by given position

$string = 'Some string'; $pos = 5; ...??... $begging // == 'Some s'; $end // == 'tring'; What is the best way to separate string in two by given position? ...

Concatenating strings to "sets" in Java

Not sure how to word this algorithm question, actually. I have toggle buttons in an android app, each corresponding to a numbered channel. Channels are (1,n) but the toggle button ids are some unknown, unsequential (to the buttons) integer. I need to collect the channel numbers and build a command string. My 1995-based Java skills have g...

remove carriage return only inside the span with regexp

I have this piece of text in a string: <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" align="center"><i style=""><span style="" lang="ES-TRAD">some text another text<o:p></o:p></span></i></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: center; line-height: normal;" al...

Splitting variable length delimited string across multiple rows (SQL)

I have a table that contains in one column a variable length delimited string for example: 20,0, 5,,^24,0, 0,,^26,0, 0,,^ 281,0, 0,,^34,0, 2,,^48,0, 2,,^44,0, 2,,^20,0, 10,,^ 20,5, 5,,^379,1, 1,,^26,1, 2,,^32,0, 1,,^71,0, 2,,^ What i need to do is split this string so that each number after the ^ character is returned on a new ...

How to efficiently overwrite parts of a string by index in .NET ?

Hi, In my .NET program I allow a user to define "fields" which are values calculated by the business logic. These fields have a position and length, so that they can all be inserted into a single output string at a given index. I also allow a user to specify default content of this output string. If no field is defined to replace a give...