string

C++ getline or cin not accepting a string with spaces, I've searched Google and I'm still stumped!

First of all, thanks to everyone who helps me, it is much appreciated! I am trying to store a string with spaces and special characters intact into MessageToAdd. I am using getline (cin,MessageToAdd); and I have also tried cin >> MessageToAdd;. I am so stumped! When I enter the sample input Test Everything works as intended. Ho...

PHP Regex Help for parsing String

I have a string such as the following: Are you looking for a quality real estate company? <s>Josh's real estate firm specializes in helping people find homes from [city][State].</s> <s>Josh's real estate company is a boutique real estate firm serving clients locally.</s> In [city][state] I am sure you know how difficult ...

How to determine where's the place of number in a string

How to determine after which comma is the place of the number 13 in a string with commas(,) with JS? For example: string - testtest,teststestatestb,testj The letter "s" is the 13-th letter and it's after the first comma. ...

Questions on C strings

I am new to C and I am very much confused with the C strings. Following are my questions. Finding last character from a string How can I find out the last character from a string? I came with something like, char *str = "hello"; printf("%c", str[strlen(str) - 1]); return 0; Is this the way to go? I somehow think that, this is not th...

PHP - Strings - Remove a HTML tag with a specific class, including its contents

I have a string like this: <div class="container"> <h3 class="hdr"> Text </h3> <div class="main"> text <h3> text... </h3> .... </div> </div> how do I remove the H3 tag with the .hdr class using as little code as possible ? ...

Text Editing Question

I'm traversing a text file line by line adjusting the text so that the file eventually will match the syntax required to be run on a MIPS simulator (MARS). My issue is that whenever I see a line with the string "blezl" in it, I want to do several things. First I need to insert some lines of text following the line containing this word. T...

Stripping the single quote (') character from a Python string

I need to strip the character "'" from a string in python. how do I do this? I know there is a simple answer. Really what I am looking for is how to write ' in my code. for example \n = newline. ...

python: how to find \r\n\r\n in one single search

I have to split the file content based on first occurrence of \r\n\r\n I need flexibility such a way that the lines can just ends with \r\n\r\n or \n\n. How to split the text? Example added: \===================FILE BEGIN========================================== name: about title: About publish: True order: -1 \r\n \r\n examp...

Case insensitive std::string.find()

I am using std::string's find() method to test if a string is a substring of another. Now I need case insensitive version of the same thing. For string comparison I can always turn to stricmp() but there doesn't seem to be a stristr(). I have found various answers and most suggest using Boost which is not an option in my case. Addition...

jQuery .each() with string

How do I use jQuery .each() on a string // For Exmaple var mystring = '<div> bleh content </div> <div> bleh content </div>'; $('div', mystring).each(function(e) { alert('do something'); }); // the above code isnt launching an alert for each div in the string? Im not sure why? ...

perl: how do I read all lines from a file and print as one line of text

I am trying to return the output of a file replacing newlines with \n without using CPAN Here is what I have so far #! /usr/local/bin/perl if ( $#ARGV = "1" ) { print "$ARGV[0]\n"; my $file = "$ARGV[0]"; my $document = do { local $/; open my $fh, "<", $file or die "could not open $file: $!"...

how to optimize a wordlist for the english language

i'm looking to optimize a wordlist for the english language using sed or a similar linux application.. in order to do this i need to: Remove lines containing anything except a-z, 0-9, or special characters Remove urls - maybe detection of the "\" character Remove lines over 16 characters long, and 4 characters or shorter. (5-16 chars...

Position of first word of string in Javascript

I originally used indexOf to find a space but I want to find any word boundary. Something like this, but what regex? var str = "This is a sentence", firstword = str.search(""); return word; I want to return "This". Even in the case of a tab, period, comma, etc. ...

String length in Scheme

Hi All, I am not able to understand the error with the code below which simply prints the length of the string: (define codeLen (read)) (display codeLen) (define code (read)) (display code) (string-length code) I am getting an error : string-length: expects argument of type <string>; given a regards, darkie ...

C# - swap Last,First MI fastest way

Ok, I can certainly do this with some IndexOf, or even a Split(), but I thought I'd throw this out as a bit of a performance teaser. I have data - like 100K's of these - in LastName,FirstName Mi and I need to make it FirstName Mi Lastname. I think that SubString/IndexOf(',') can do the job, but was hoping for a more elegant/performan...

PHP - Removing <?php ?> tags from a string

What's the best way to remove these tags from a string, to prepare it for being passed to eval() ? for eg. the string can be something like this: <?php echo 'hello world'; ?> Hello Again <?php echo 'Bye'; ?> Obviously str_replace won't work because the two php tags in the middle need to be there (the the 1st and the last n...

Replace string that contain #0?

I use this function to read file to string function LoadFile(const FileName: TFileName): string; begin with TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite) do begin try SetLength(Result, Size); Read(Pointer(Result)^, Size); except Result := ''; Free; raise; end; Free; ...

string concatenation with strncat leads to error in signedness

update: the point of whether char, signed char, or unsigned was ultimately moot here. it was more appropriate to use memcpy in this situation, since it works indiscriminately on bytes. Couldn't be a simpler operation, but I seem to be missing a critical step. In the following code, I am attempting to fill bufferdata with buffer for wh...

When using String.Format is there a simple way to add parenthesis around a string value if it is not null or empty.

I am attempting to isolate (for localization purposes) the formatting of some messages. In one of the cases, I have several parameters, some of which may be an empty string. An example is probably called for here.... If the parameters are Parameter one and Parameter two then I want the result to be Some message Parameter one (Parameter ...

building a search from split(": ") and indexing it into object

Hey all, In the below javascript, "this" refers to Car object and search_id refers to the input text field with an id of "search_input". So basically the user types in text in the field and a search occurs based on the input. Now I understand that the val() method is grabbing the user input string from the input field. However, I am not...