ok. i think you could take a simpler approach then, eg
var pattern:RegExp = new RegExp('\"title\":\"([a-zA-Z ]+)','i');
var str:String = '"title":"houses or houses","count":
47,"group":true,"connection":39,';
trace(str.match(pattern)[1]);
returns
houses or houses
ie, the matched string is '"title":"houses or houses' and the bit that
matched the parentheses is "houses or houses".
Just add whatever characters are valid for the title into the
character set [a-zA-Z ]. Or you could let it match everything that's
not a comma or double-quote buy doing this:
var pattern:RegExp = new RegExp('\"title\":\"([^,\"]+)','i');
var str:String = '"title":"houses or houses","count":
47,"group":true,"connection":39,';
trace(str.match(pattern)[1]);
also returns
houses or houses
HTH
Guy
On 14/01/2009, at 1:55 AM, flexaustin wrote:
Yeah that works sort of. The issue is that I need to stop before or
right after a "," series.
So given this string:
"title":"houses","count":47,"group":true,"connection":39,
I need to stop when I get "title":"houses"," or "title":"houses" or
"title":"houses or houses. I am trying to extract whatever is given
for title, which in this example is houses.
Thanks
--- In flexcoders@yahoogroups.com, Guy Morton <g...@...> wrote:
>
> Is your data actually split over multiple lines? Or is it just
> wrapping in the email?
>
> The problem, I think, is in your second set of parentheses. You
search
> for "," followed by 0 or more word characters, then a colon. That
> pattern does not appear in your search string.
>
> Also, that .* between your two sets seems a little odd. It will
match
> everything between your first and second matches. But perhaps that's
> what you want.
>
> This successfully matches your string...maybe it will help you?
>
> var pattern:RegExp = new RegExp('(\"name\":\").*(\",\"[a-zA-Z]*
> \":)','i');
>
> This matches "name":" and ","id":
>
> Generally speaking, I find the easiest thing to do with regexps is
to
> make them smaller and get the smaller ones working first then string
> them together.
>
> regards
>
> Guy
>
> On 13/01/2009, at 6:01 PM, flexaustin wrote:
>
> > pattern = new RegExp('(?<=\"name\":\").*(?=\",\"\w*:)', 'i');
> > var resultArr:Array = pattern.exec(data);
> >
> > resultArr ends up equaling null;
> >
> > But if you check this: (?<=\"name\":\").*(?=\",\"\w*:) using
> > http://gskinner.com/RegExr/ it says it works using this data
> >
> > "error":32,"count":47,"group":true,"connection":39,"warning":
> > 3
> > ,"name
> > ":"Workstations
> > ","title":"Workstations","model":"workstation","ticket":
> > 1,"type":"TagCategory","id":1
> >
> > So why is it not working in my code? If anyone has any
suggestions I
> > would appreciate it. I have been trying to get this to work for 10
> > hours straight.
> >
> > TIA
> >
> >
> >
>