The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Regular expresion
jmphillips
Member Posts: 18 Contributor II
in Help
I want to recognize some regular expresion, for example "my cat", and then obtain the next´s word until a point followed or a separate point. the object is to obtain definitions from a text. for example:
A hammer is a tool that consists of a heavy piece of metal at the end of a handle. It is used, for example, to hit nails into a piece of wood or a wall, or to break things into pieces. He used a hammer and chisel to chip away at the wall.
the idea si: set hammer as my regular expresion that i want to identify and then obtain as result "is a tool that consists of a heavy piece of metal at the end of a handle."
How can I do this????
How can I do this????
0
Best Answer
-
btibert Member, University Professor Posts: 146 GuruI am doing this without regex. In your case, why not just filter examples where the text contains hammer? I attached a very very basic example.
6
Answers
So basically this means you have your word, followed by any word character (a to z, 0 to 9 and _) or space.
This will end your result on any punctuation, but you can extend the list of 'good ones' at will
I have a question: how can I extend until to punctuation????, including colon (,)
like: " the big hammer is in the forrest, and you know it."
and return to me: "the big hammer is in the forrest, and you know it."
not returning: "the big hammer is in the forrest"
In the [] context you can always list the characters you want to include. \w is a shortcut for word characters. If you want "word characters, space and comma", the regular expression would be:
Regards,
Balázs