[tw] Re: Help needed for an experimental plugin : strange behaviour of a textarea element

2010-07-29 Thread FrD
Thanks
The problem was when the regexp was executed.
When the textarea contains an \n, the pattern constructed with this
value did not produce what I wanted when passed to exec ; I had to
escape regexp in the string (i.e. the section value) before
constructing the pattern.

FrD

On 28 juil, 23:54, PMario pmari...@gmail.com wrote:
 Hi,
 I think your regexp is wrong

 test this. It is not a solution, but may be some pointers.

 var text = store.getTiddlerText(tid.title+'##JSON',{});

 var pattern = /(!{1,6}JSON[\s\S\n])([\s\S\n]*)(!{1,6}EndJSON)/im;
 var te = pattern.exec(text);
 if (te != null) {
         result[0] = te[0];
         oldval = te[1];
         result[2] = te[2];} else {
         result[0] = ;
 }

 console.log('parts: ', result)

 This is, what the regexp does. lines not starting with an x are broken
...
 Mario

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: Help needed for an experimental plugin : strange behaviour of a textarea element

2010-07-28 Thread FrD
Found it !

I had to use escapeRegExp() when getting the value of section.
Unless that there was a bug when processing  a \n inside the
section.

Now it works.

On 28 juil, 20:50, FrD sokus...@gmail.com wrote:
 Hello,

 I'm trying to do some simple work in javascript :-)
 ...
 FrD

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: Help needed for an experimental plugin : strange behaviour of a textarea element

2010-07-28 Thread FrD


On 28 juil, 23:49, FrD sokus...@gmail.com wrote:
 Found it !

 I had to use escapeRegExp() when getting the value of section.

Thanks to   Eric Shulman's  GridPlugin !!!

FrD

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.



[tw] Re: Help needed for an experimental plugin : strange behaviour of a textarea element

2010-07-28 Thread PMario
Hi,
I think your regexp is wrong

test this. It is not a solution, but may be some pointers.

var text = store.getTiddlerText(tid.title+'##JSON',{});

var pattern = /(!{1,6}JSON[\s\S\n])([\s\S\n]*)(!{1,6}EndJSON)/im;
var te = pattern.exec(text);
if (te != null) {
result[0] = te[0];
oldval = te[1];
result[2] = te[2];
} else {
result[0] = ;
}
console.log('parts: ', result)

This is, what the regexp does. lines not starting with an x are broken
by the list

x( +  // Match the regular expression below and capture
its match into backreference number 1
x   ! +  // Match the character “!” literally
x  {1,6} +  // Between one and 6 times, as many times as
possible, giving back as needed (greedy)
x   JSON +   // Match the characters “JSON” literally
x   [\\s\\S\n] +   // Match a single character present in the
list below
x // A whitespace character (spaces, tabs, and
line breaks)
x // Any character that is NOT a whitespace
character
x // A line feed character
x) +
x( +  // Match the regular expression below and capture
its match into backreference number 2
x   [\\s\\S\n] +   // Match a single character present in the
list below
x // A whitespace character (spaces, tabs, and
line breaks)
x // Any character that is NOT a whitespace
character
x // A line feed character
x  * +  // Between zero and unlimited times, as many
times as possible, giving back as needed (greedy)
x) +
x( +  // Match the regular expression below and capture
its match into backreference number 3
x   ! +  // Match the character “!” literally
x  {1,6} +  // Between one and 6 times, as many times as
possible, giving back as needed (greedy)
x   EndJSON +// Match the characters “EndJSON” literally
x)

hope this helps
have fun!
Mario

-- 
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.