સુધારો કરવા માટે અમારા Platinum સેવા અને વિચાર તમારા પોતાના વૈવિધ્યપૂર્ણ રચાયેલ 3D અવતાર
Self, AIML, and scripting

star (parameter with space or dash)

દ્વારા Schrader પોસ્ટ Mar 22 2018, 10:58

Hi, I have a pattern with 3 stars, pattern "* * *" template relearn();

then I can read sigle parameters by using:

var brand = sentence.get(#word, 0);
var series = sentence.get(#word, 1);
var year = sentence.get(#word, 2);

but one of the parameter can have space for example par1 par2 par 3

so the words become 4 becose a space.

I have to read 3 parameters from the 3 starts

How can I solve this situation ? 

 

Also if the user input 1par 2-par 3par, the second parameter is ignored I mean in #word1 I find obly 2 and not 2-par

 

 Thanks in advance


by admin posted Mar 22 2018, 13:43
To access * wildcards from a pattern use the "star" variable. For multiple stars this will be an array.

i.e.
var brand = star[0];
var series = star[1];
var year = star[2];

The star will be the whole string fragment matched to the wildcard.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2700, today: 3, week: 7, month: 12

ને: 21407233
ટૅગ્સ: star (parameter with space or dash)
પોસ્ટ: Mar 22 2018, 10:58
જવાબો: 1
જોવાઈ: 2550, આજે: 2, સપ્તાહ: 5, મહિને: 13
0 0 0.0/5