0

From a 3rd party tool we got some text. I have to create an application which read the text and extract the text from a attribute.

BodyItems=[[Length=45, Text="Emphasis on subjective\, conscious experience "], [Length=47, StartIndex=45, Text="How you think\, feel\, perceive your social world"], [IndentationLevel=1, Length=38, StartIndex=92, Text="Chapter 12:  Personality and Cognition"], [IndentationLevel=1, Length=37, StartIndex=130, Text="Chapter 14:  Personality and the Self"], [IndentationLevel=1, Length=36, StartIndex=167, Text="Chapter 17:  Personality and Culture"]]

I need to create a regex which process the above line of text and list the text which are wrapped inside Text="........"]. I tried to create a regex but it has only one match . Here is my regex

string strRegex = @"Text=\""[\w\W]*\""\]";

I want to create a regex which give the below output

  • Text="Emphasis on subjective\, conscious experience "]
  • Text="How you think\, feel\, perceive your social world"]
  • Text="Chapter 12: Personality and Cognition"]
  • Text="Chapter 14: Personality and the Self"]
  • Text="Chapter 17: Personality and Culture"]
madan
  • 773
  • 13
  • 38
  • 1
    How about: `Text="[^"]+"\]` – Toto Mar 07 '17 at 10:32
  • 1
    Use [`string strRegex = @"Text=""[\w\W]*?""]";`](http://regexstorm.net/tester?p=Text%3d%22%5b%5cw%5cW%5d*%3f%22%5d&i=BodyItems%3d%5b%5bLength%3d45%2c+Text%3d%22Emphasis+on+subjective%5c%2c+conscious+experience+%22%5d%2c+%5bLength%3d47%2c+StartIndex%3d45%2c+Text%3d%22How+you+think%5c%2c+feel%5c%2c+perceive+your+social+world%22%5d%2c+%5b...%2c+Text%3d%22Chapter+12%3a++Personality+and+Cognition%22%5d%2c+%5bIndentationLevel%3d1%2c+Length%3d37%2c+StartIndex%3d130%2c+Text%3d%22Chapter+14%3a++Personality+and+the+Self%22%5d%2c+%5b...%2c+Text%3d%22Chapter+17%3a++Personality+and+Culture%22%5d%5d). – Wiktor Stribiżew Mar 07 '17 at 10:34
  • Thank you both for your time, both are working for me :) – madan Mar 07 '17 at 11:02

0 Answers0