Regex in xCode: any number of any whitespace characters including "end of line"?

794 views Asked by At

I my case I have the following text:

- (NSUInteger) launcherView:(HMLauncherView *)launcherView 
        numberOfIconsInPage:(NSUInteger)page;

And I want to find all the matches for this method. The regexp should look like something like this:

launcherView:<any number of characters><any number of whitespaces or "ends of line">numberOfIconsInPage:

I know <any number of characters> means (.+) and <whitespace> means \s but how to write the whole expression? My main problem - I can't make it searching for any combination of whitespaces because it differs whitespace characters and "end of line".

1

There are 1 answers

1
nerdbeere On BEST ANSWER

The Regex could be this one:

/launcherView:.+(\s*|\s*$)numberOfIconsInPage:/

In particular, the ".+" matches any character, the (\s*|\s*$) matches either only whitespaces until the "numberOfIconsInPage" or any number of whitespaces until the end of line.