Reputation: 935
One of the column in my table have data like this
@Stream<TTL>@Topic<Abstimmung_Carbon_Accounting>@Date<03-May-2012<@Time<BN,APH>@Participants<MUELLER,RECHTE>@Pages<2>
@Stream<m20>@Topic<Shared_Space_Afternoon>@Date<12.10.12>@Time<Call>@Participants<dehaan>@Pages<2>
What I want is to select the Topic
part only, using mysql query. Regex for this is something like Topic\<\w+\>
But how to use it to select part from a field in mysql.
Output needed:
Abstimmung_Carbon_Accounting
Shared_Space_Afternoon
Thanks for your help.
Upvotes: 0
Views: 119
Reputation: 8761
You can solve this problem without using regex
Assume you have a table table2
with one column col1
of varchar
type and it contain following values
@Stream<TTL>@Topic<Abstimmung_Carbon_Accounting>@Date<03-May-2012<@Time<BN,APH>@Participants<MUELLER,RECHTE>@Pages<2>
@Stream<m20>@Topic<Shared_Space_Afternoon>@Date<12.10.12>@Time<Call>@Participants<dehaan>@Pages<2>
Then you can use following query to get your required output
select substring(col1,Locate('Topic<',col1)+6,(Locate('>',substring(col1,Locate('Topic<',col1)+6))-1)) as result from table2
where substring(col1,Locate('Topic<',col1))!=""
Upvotes: 1