TS91 Posted September 26, 2013 at 09:31 PM Report #526196 Posted September 26, 2013 at 09:31 PM Boas, estou a tentar obter uma string de um ficheiro atraves do preg match. Eu tenho algo do genero: /** Category Template: nome */ mais texto. Eu queria verificar se existe em a parte de "Category Template: nome" e returnar para uma string Alguem tem ideia de que pattern necessito para o preg_match? Cumprimentos
Rui Carlos Posted September 26, 2013 at 09:48 PM Report #526200 Posted September 26, 2013 at 09:48 PM Algo deste género deve funcionar: $matches = null; $flag = preg_match('/\\/\\*\\*\\s*Category\\sTemplate:\\s*([a-zA-Z0-9\\s_-]*)\\n/', $txt, $matches); $name = $matches[1]; http://ideone.com/iibUqE Atenção à parte final da expressão regular, pois não sei que caracteres o nome do template pode conter. Rui Carlos Gonçalves
TS91 Posted September 26, 2013 at 10:26 PM Author Report #526205 Posted September 26, 2013 at 10:26 PM Funcionou lindamente, obrigado.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now