我需要一种方法来搜索子字符串,只要它是一个完整的单词。
理想情况下,我想要一个函数(比如//
// ViewController.m
// UseMyBeacon
//
//
#import "ViewController.h"
@import CoreLocation;
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
NSUUID *proximityUUID = [[NSUUID alloc]initWithUUIDString:@"39ED98FF-2900-441A-802F-9C398FC199D2"];
CLBeaconRegion *thisRegion = [[CLBeaconRegion alloc] initWithProximityUUID:proximityUUID identifier:@"com.mycompany.myregion"];
self.region = thisRegion;
Boolean b = [CLLocationManager isMonitoringAvailableForClass:[thisRegion class]];
if (b) {
// Create the beacon region to be monitored.
// CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc]
// initWithProximityUUID:proximityUUID
// identifier:identifier];
// Register the beacon region with the location manager.
self.locationManager.delegate = self;
[self.locationManager startMonitoringForRegion:thisRegion];
}
}
- (void)locationManager:(CLLocationManager *)manager
didEnterRegion:(CLRegion *)region{
}
- (void) locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
{
[self.locationManager requestStateForRegion:self.region];
}
- (void)locationManager:(CLLocationManager *)manager
rangingBeaconsDidFailForRegion:(CLBeaconRegion *)region
withError:(NSError *)error{
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error{
}
- (void) locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{
switch (state) {
case CLRegionStateInside:
[self.locationManager startRangingBeaconsInRegion:self.region];
break;
case CLRegionStateOutside:
case CLRegionStateUnknown:
default:
// stop ranging beacons, etc
NSLog(@"Region unknown");
}
}
- (void) locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
{
if ([beacons count] > 0) {
// Handle your found beacons here
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
)这样两个例子,
findwstring()
$(findwstring a, a b c)
应分别生成值'a'和''(空字符串)。
我无法找到任何可以帮助我的here。
答案 0 :(得分:2)
$(filter a, a b c)
制作'a'
。
$(filter a, angle b c)
制作''
。
搜索字符串中的百分比(%
)被视为通配符。
来自您关联的文档(实际上是findstring
下面的函数),粗体我的:
$(filter pattern…,text)
返回做匹配任何模式字词的文本中的所有以空格分隔的单词,删除不包含的任何字词匹配。模式使用'%'编写,就像上面
patsubst
函数中使用的模式一样。
filter
函数可用于在变量中分离出不同类型的字符串(例如文件名)。例如:sources := foo.c bar.c baz.s ugh.h foo: $(sources) cc $(filter %.c %.s,$(sources)) -o foo
表示
foo
取决于foo.c
,bar.c
,baz.s
和ugh.h
,但只有foo.c
,bar.c
和{应在编译器的命令中指定{1}}。