views:

104

answers:

1

I'm trying to split these into tokens and it's mostly there. I really want to split the primary tokens up like NIGHT, set, the xpath pattern, the value to assign to the xpath pattern, i.e. in the second one, 'high' and in the second one, 'taken-offline' and the '-' and '+'.

NIGHT.set('.//idmef:Source[1]','+')
NIGHT.set('.//idmef:Assessment/idmef:Impact/@severity', 'high')
NIGHT.set('/idmef:IDMEF-Message/idmef:Alert/idmef:Source[1]/@ident', 'taken-offline', '-')

They are expressions which map XML to a specific pattern state. But when I run the following regexp on them, I still seem to leave these in.

public static string[] Tokenize(string ActionItem)
{
   Regex RE = new Regex(@"([(\.\//\s\;\,\:\.\)]+)");
   return (RE.Split(ActionItem));
}

When I run it, I get the following:

NIGHT
.
set
(
'
.//
idmef
:
Assessment
/
idmef
:
Impact
/
@severity'
,
'high'
)


NIGHT
.
set
(
'
.//
idmef
:
Source[1]'
,
'+'
)


NIGHT
.
set
(
'
/
idmef
:
IDMEF-Message
/
idmef
:
Alert
/
idmef
:
Source[1]
/
@ident'
,
'taken-offline'
,
'-'

Its that ', I don't know what you call it, single quotation mark, it is still being left in.

What am I doing wrong?

A: 

Try this pattern, works fine here. It matches the " ' " , but does not include it into split result (hence it's outside the parenthses

'?([(\.\//\s\;\,\:\.\)]+)'?
iamruss
It's very close but it is leaving a space between the opening bracket and the firs .// or /.B
scope_creep
Its close enough. B
scope_creep