Reputation: 115
I have this kind of line :
#RT_POOL_CELL1_1 : RT_CELL_T := (NEXT => 0,
#RT_IS_OK : BOOLEAN := TRUE;
#RT_RESULT_UPDATE_TM_INFO.TC_INFO : PUS.TYPES.RESULT_UPDATE_TM_INFO_T := PUS.TYPES.UPDATE_OK;
And I need to take RT_POOL_CELL1_1, RT_IS_OK and RT_RESULT_UPDATE_TM_INFO (without the dot .TC_INFO) in java with regex.
I tried to make that with this regex : \s*[#][[:ascii:]]\s*[:|.]
But it doen't work. The thing to know is the word I need to take is always between # and :, they can contains space between word et sign. And if there is a ., I juste take the word before the dot.
Thank's for your help.
Upvotes: 1
Views: 55
Reputation: 784878
You can use this regex based on lookarounds:
(?<=#)[^:.]+?(?= *[:.])
Breakup of regex:
(?<=#) # makes sure there is preceding #
[^:.]+? # match anything but : or . (non-greedy)
(?= *[:.]) # makes sure this is followed by 0 or more spaces and : or .
Upvotes: 2