substring

How can I take the first 100 characters of html content ( without stripping the TAGS! )

There are lots of questions on how to strip html tags, but not many on functions/methods to close them. Here's the situation. I have a 500 character Message summary ( which includes html tags ), but I only want the first 100 characters. Problem is if I truncate the message, it could be in the middle of an html tag... which messes up stu...

Using constructor to load data in subsonic3?

I'm getting an error while trying to load an record through the constructor. The constructor is: public Document(Expression<Func<Document,bool>> expression); and i try to load a single item in like this var x = new Document(f=>f.publicationnumber=="xxx"); publicationnumber isn't a key but tried making an it an unique key and stil...

jQuery changing fields to substring of related field

Another jquery calculation question. I've this, which is sample code from the plugin site that I am playing with to get this working: function recalc(){ $("[id^=total_item]").calc( "qty * price", { qty: $("input[name^=qty_item_]"), price: $("input[name^=price_item_]"), }, fu...

Batch file: Extracting substring from input parameter to use in IF statement

This is a very basic example of what I am trying to implement in a more complex batch file. I would like to extract a substring from an input parameter (%1) and branch based on if the substring was found or not. @echo off SETLOCAL enableextensions enabledelayedexpansion SET _testvariable=%1 SET _testvariable=%_testvariable:~4,3% ECHO...

validating a string in php if only substring is true

How to validate a substring is true in PHP for example if user1 is in the string it should be true? textfile: user1 : pass1 user2 : pass2 user3 : pass3 if(in_array($_SERVER['user1'] . "\r\n", $textfile)){ //not the way want this to be true printf("Ok user1 is in this row somewhere"); } ...

Java strings and substrings

hey folks, Can someone help me with this Java problem? I want to write a method that takes two strings as arguments and returns true if each character (including space and punctuation) that appears in one string also appears in the other. Thanks ...

Find substring ignoring specified characters

Do any of you know of an easy/clean way to find a substring within a string while ignoring some specified characters to find it. I think an example would explain things better: string: "Hello, -this- is a string" substring to find: "Hello this" chars to ignore: "," and "-" found the substring, result: "Hello, -this" Using Regex is no...

C: evaluate part of the string

I cant find an expression to evaluate a part of a string. I want to get something like that: if (string[4:8]=='abc') {...} I started writing like this: if (string[4]=='a' && string[5]=='b' && string[6]=='c') {...} but if i need to evaluate a big part of string like if (string[10:40] == another_string) {...} then it gets to wri...

How to split string in group in vb.net

Hi. i'm amol kadam,I want to know how to split string in two part.My string is in Time format (12:12).& I want to seperate this in hour & minute format.the datatype for all variables are string. for hour variable used strTimeHr & for minute strTimeMin .I tried below code but their was a exception "Index and length must refer to a locatio...

How to get specific line from a string in C#?

I have a string in C# and would like to get text from specific line, say 65. And if file does not have so many lines I would like to get "". How to do this? ...

How can you tell MYSQL to TRIM the X number of characters, beginning from the Back?

How do I write the following in MYSQL? SELECT SUBSTRING(value - (1 TRAILING CHARACTER)) FROM table; Basically substring(value, 2) trims the first letters. But I need to trim the last letters. I can't use substring(value, -4, 3) because I don't know the length of the value. Here's another example: SELECT * FROM table WHERE SUBSTRING(va...

C - check if string is a substring of another string

I need to write a program that takes two strings as arguments and check if the second one is a substring of the first one. I need to do it without using any special library functions. I created this implementation, but I think it's always returning true as long as there is one letter that's the same in both strings. Can you help me out h...

How can I use IndexOf to pick a specific Character when there are more than one of them?

How can I use IndexOf with SubString to pick a specific Character when there are more than one of them? Here's my issue. I want to take the path "C:\Users\Jim\AppData\Local\Temp\" and remove the "Temp\" part. Leaving just "C:\Users\Jim\AppData\Local\" I have solved my problem with the code below but this assumes that the "Temp" folder is...

PHP find first of occurrence of string

I have a string of data like below and I've been struggling trying to figure out how to split it up so that I can use it efficiently. "United States FirstName: Mike LastName: Doe City: Chicago" I need to split up the string in to substrings and the list may not always be in the same order. For example it could vary like below: "Un...

named_scope and substings

I have a named_scope in rails that finds episodes by there directors given name named_scope :director_given, lambda { |dr| {:joins => :director, :conditions => ['given = ?', dr]} } It works great but I would like it to also work on substrings one the name. e.g. instead of having to search for 'Lucy' you could just search 'Lu'. P.S....

substring using bat command

Hi all, I have the following thing in my bat file. say set path=c:\temp\test so basically i want to have an output which would give me the result as c:\temp\ i didnt find any indexof equivalent in bat command. Thanks. ...

Break NSString using an NSString, get everything after the string that was used to break/separate.

I'm trying to get the DOE,JOHN from the below NSString: IDCHK9898960101DL00300171DL1ZADOE,JOHN I was trying to split the string on 1ZA, as that will be constant. Here's what I've tried so far, but it's giving me the opposite of what I'm looking for: NSString *getTheNameOuttaHere = @"IDCHK9898960101DL00300171DL1ZADOE,JOHN"; // sca...

xpath help substring expression

Hi i have a document from which i am trying to extract a date. But the problem is within the node along with the date their is some text too. Something like <div class="postHeader"> Posted on July 20, 2009 9:22 PM PDT </div> From this tag i just want the date item not the Posted on text. something like ./xhtml:div[@...

String contains string in objective-c (iphone)

How can I check if a string (NSString) contains another smaller string? I was hoping for something like: NSString *string = @"hello bla bla"; NSLog(@"%d",[string containsSubstring:@"hello"]); But the closest I could find was: if ([string rangeOfString:@"hello"] == 0) { NSLog(@"sub string doesnt exist"); } else { NSLog(@"exist...

Given an array of arrays, how can I strip out the substring "GB" from each value?

Each item in my array is an array of about 5 values.. Some of them are numerical ending in "GB".. I need the same array but with "GB" stripped out so that just the number remains. So I need to iterate through my whole array, on each subarray take each value and strip the string "GB" from it and create a new array from the output. Can a...