Created
September 2, 2012 19:34
-
-
Save tmdvs/3603700 to your computer and use it in GitHub Desktop.
Help my broken brains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following doesnt work for some reason and it's really hurting my brains. | |
The variables contents are: | |
=========================== | |
myString = <script src="/mint/?js" type="text/javascript"> | |
matchedString = ?js" | |
I'm finding the range: | |
====================== | |
NSRange matchRange = [[myString string] rangeOfString:matchedString options:NSLiteralSearch]; | |
The output is as follows: | |
========================= | |
matchRange.location = 0.000000; | |
matchRange.length = 0.000000; |
Try switching s.string
and match
? It seems like you're looking for the big string in the little string?
Have you tried escaping the quote and/or the question mark with a \
? Unlikely that would have any effect, but worth a try...
This is a much more realworld example. As you can see there is a ? in the search string!
NSRange location = [s.string rangeOfString:@"?" options:NSAnchoredSearch];
NSLog(@"%@", s.string);
NSLog(@"Loc: %d, Len %d", location.location, location.length);
outputs:
[Line 110] <script src="/mint/?js" type="text/javascript"></script><script type="text/javascript" src="http://tmdvs.me/mint/?record&key=32664866363337313636345433584f7873686963645471474b31&referer=&resource=http%3A//tmdvs.com/&resource_title=Tim%20Davies%20sans%20vowels&resource_title_encoded=0&resolution=768x1024&flash_version=0&1346617362934&serve_js"></script>
[Line 111] Loc: 2147483647, Len 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happens if you search without the
NSLiteralSearch
option?