Regex get string from string

YosiFZ

I have NSString that contain this string :

c&&(b.signature=Rk(c));return ql(a,b)}

The RK can be any two chars.

I try to get the RK from the string with (RegexKitLit):

NSString *functionCode = [dataStr2 stringByMatching:@".signature=(.*?)\(" capture:1L];

and functionCode is always nil.Any idea what wrong?

rmaddy

Don't bother with regular expressions for this. If the format of the string is always the same then you can simply do:

NSString *dataStr2 = @"c&&(b.signature=Rk(c));return ql(a,b)}";
NSString *functionCode = [dataStr2 substringWithRange:NSMakeRange(16, 2)];

If the string is not quite so fixed then base it on the position of the =.

NSString *dataStr2 = @"c&&(b.signature=Rk(c));return ql(a,b)}";
NSRange equalRange = [dataStr2 rangeOfString:@"="];
NSString *functionCode = [dataStr2 substringWithRange:NSMakeRange(equalRange.location + equalRange.length, 2)];

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

get the number from string by regex

From Dev

Get resource from RegEx String

From Dev

Use RegEx to get (parsed) times from string

From Dev

Get KeyValuePair into Array from string using regex

From Dev

Regex to get SLD + TLD from domain string

From Dev

Java Regex to get a word from a String

From Dev

How to get number from string using Regex?

From Dev

Regex to get YouTube URL from string

From Dev

Get last n matches from String with regex

From Dev

Get style attributes with regex from html string

From Dev

How to get a number from a string with regex

From Dev

JavaScript Regex - Get Nth digits from string

From Dev

get content from string php regex

From Dev

Get a substring from a string using regex

From Dev

How to get number from string using Regex?

From Dev

Get last n matches from String with regex

From Dev

Regex to get <a href> from a string in java

From Dev

Get substring from string date using regex

From Dev

Get value from string if finded match regex

From Dev

Get style attributes with regex from html string

From Dev

Regex: Get value of height from a string in JavaScript

From Dev

Regex to get some values from an input string

From Dev

Get substring from string using regex in ruby

From Dev

How to get a string from an input string defined within a frame with regex

From Dev

Match string and number with Regex to get the item and quantity from the string

From Dev

Regex: extract String from String

From Dev

Regex: extract String from String

From Java

Regex get string between ()

From Dev

Get string between with regex