我想找到以某个单词开头和某个单词结尾的句子。 例如,以“ Hello”开头,再见“ Helloxxxxxxxgoodbye”结束的句子
答案 0 :(得分:-1)
使用/Hello.*goodbye/
来匹配所有字符,因此找到以Hello开头并告别的东西将是- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
if (!context || ![EAGLContext setCurrentContext:context]) {
NSLog(@"Failed to create ES context");
}
GLKView *view = (GLKView *)self.view;
view.context = context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat16;
glEnable(GL_DEPTH_TEST);
shader = [[BaseEffect alloc] initWithVertexShader:@"Shader.vsh"
fragmentShader:@"Shader.fsh"];
// setup projection and model matrix
}
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearDepthf(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
[shader prepareToDraw];
// draw point
glBindVertexArray(vertexArray);
glDrawArrays(GL_POINTS, 0, pointsCount);
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint tapLoc = [touch locationInView:self.view];
GLfloat depth = 0;
glReadPixels(tapLoc.x, tapLoc.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
NSLog(@"Depth %f", depth);
}
。
一个测试正则表达式的好网站是https://regex101.com/
希望这会有所帮助。