0

The issue is I have to tokenize data into tokens based on spaces at the same time I can't tokenize the data based on special characters. Right now the regex I have is

       (\w*[-*#+=;:\/,~_ ]*\w+)

With this when I process the string

    1-CHECK ON BLOCKS BELOW IF MARKET CORRECTION ARE LOADED: PCORP:BLOCK=ANCTRLG&V5PTCLG;   AF55722  BRTBMWA-3289 (AF55722) in block ANCTRLG (Product ID: CAAZ 107 4493 R1A10 )  AF55736  BRTBMWA-3290 (AF55726)in block V5PTCLG  (Product ID: CAAZ 107 4260 R2A08 )  IF MARKET CORRECTIONS ARE LOADED THEN V5 INTERFACE PROPERTY MUST BE DEFINED AS FOLLOW : MUXFIM : ACC-OFF (Accelerate Alligment is not active) WLL    : ACC-ON  (Accelerate Alligment is active ) :  EXAPC:V5ID=v5id,PROP=ACC-OFF; 

What it does is tokenizes the string based on spaces at the same time it also tokenizes the data based on special character like

             :  EXAPC:V5ID=v5id is tokenized to :  EXAPC, :V5ID and =v5id rather want it to split as : and EXAPC:V5ID=v5id

I want to avoid this any idea on this any help will be appreciated.

Ashit_Kumar
  • 601
  • 2
  • 10
  • 28

1 Answers1

1

Your regex matches "an optional word, then an optional list of special characters, then another word". In case you have two words, there is no option of having a special character before the first word. What you're probably looking for is ([-*#+=;:\/,~_ \w]+).

Hetzroni
  • 2,109
  • 1
  • 14
  • 29