Questions tagged [strstr]

A function that searches a string in another string.

A function that searches a string in another string.

Examples

php
$email  = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // prints @example.com

(Example taken from php.net)

Resources

363 questions
0
votes
2 answers

Compare popularity of keywords within string

I want to take a long string (hundreds of thousands of characters) and to compare it against an array of keywords to determine which one of the keywords in the array is mentioned more than the rest. This seems pretty easy, but I am a bit worried…
Or Weinberger
  • 7,332
  • 23
  • 71
  • 116
0
votes
3 answers

Take a part of a big text

Let's say we have a string ($text) I will help you out, if you see this message and never forget blah blah blah I want to take text from "" to "" into a new string($text2) How can this be done? I appreciate any help I can get.…
Muazam
  • 379
  • 1
  • 6
  • 15
0
votes
1 answer

Stopping strstr before it runs into sigsegv

I have a large .xml file and need to pull specific bits out of it. The things I need to pull out are encapsulated by a substring on either side. I need to write the output to a file. I'm searching for the starting sub and from there for the ending…
0
votes
1 answer

Recreating strstr()

My goal is to recreate strstr in a C function named myStrStr that returns a 1 if the substring is found in the haystack and a 0 if it is not, all while copying the matched substring into a buffer. I tried writing the following code to solve this,…
d827
  • 79
  • 7
0
votes
1 answer

How to use strstr() in C to count keywords from another file?

I am attempting to get my program to read strings from another file, parse them for certain keywords, and then add to a counting variable whenever they appear in the other file. However, I can't seem to get anything but the number of lines to count.…
0
votes
2 answers

Cut certain part of string after a specific character

I am trying to basically cut a certain part of string after a specific character and then print it. I have this string and I need to cut the part after the last "/". Which means from this string: $mystring =…
Adam Šulc
  • 526
  • 6
  • 24
0
votes
1 answer

Get the text before and after strstr in C

I need to be able to extract the characters before and after a substring, currently I have the following code: #include #include #include int main(int argc, char *argv[]){ char *text = (char *) malloc…
user10027591
0
votes
1 answer

C file to multiple char *groups by word delimiter

I have a file with content similar to below: Really my data is here, and I think its really cool. Somewhere, i want to break on some really awesome data. Please let me really explain what is going '\n' on. You are amazing. Something is really…
johnnyb
  • 1,745
  • 3
  • 17
  • 47
0
votes
1 answer

How do I use strstr in Swift to search for a string within a string?

How do I use strstr in Swift to search for a string within a string? I'm not sure how to use UnsafePointer! in Swift. strstr takes two arguments of both that type and returns a value of that type. Is this C or C++? Can I use C or C++ code in Swift,…
daniel
  • 1,446
  • 3
  • 29
  • 65
0
votes
2 answers

remove characters before and after

Here, I am using strstr to remove after characters and substr is used to remove before character. But how to remove all characters before and after at once ? I need to get only 80 from this variable $mrk = 'Science-80_John' omitting Science and…
Dipak
  • 931
  • 14
  • 33
0
votes
2 answers

PHP - strstr() returns false but the $haystack contains the $needle

This is a very strange error, i am trying to fix it without success. I am trying to check if a link contains a string: $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; echo $actual_link; The output…
Daniele
  • 129
  • 12
0
votes
1 answer

How to loop a string using strstr to find substrings in C

I'm trying to find different substrings of information from a larger string where the information is separated by ":" For example: username:id:password:info How could I using strstr function in C loop this string to extract the information into…
renshencha
  • 55
  • 6
0
votes
1 answer

I want a different variable for stuff which pass stristr but must not contain anything except those 3 different things

I have this following code:- $unitedstatess = stristr($ad['country'], 'united states'); $unitedkingdom = stristr($ad['country'], 'united kingdom'); $canada = stristr($ad['country'], 'canada'); if (($unitedstatess…
friendishan
  • 299
  • 1
  • 3
  • 9
0
votes
1 answer

strstr cannot find substring but buffer contains the value

I was trying UART using STM32F407V6T6 and CubeMx. My UART is working fine. The problem I'm getting while comparing the buffer: I am using strstr() to check that my buffer contains valid substring or not. Here is the code: uint8_t buff[10]; int…
sourav maity
  • 23
  • 1
  • 7
0
votes
1 answer

Checking if a string exists using a substring (using linked lists)

I need to make a function that receives a substring as an argument and checks if any of the strings in a linked list contain that substring. The function creates a new linked list with all of the strings that contain the substring given. The…
Herbert
  • 3
  • 3