[FX.php List] Javascript question

Dale Bengston dale.bengston at gmail.com
Mon Aug 19 16:35:12 MDT 2013


Hey Bob,

Here's another approach. Using str.split('|') will split your string into array elements at each instance of the specified delimiter character. It's just like explode() in php:

var str= '2014|Steven Patin';
var parsed_str = str.split('|');

The ID is now located in parsed_str[0] and the name is in parsed_str[1].

Hope it helps,
Dale


 --
Dale Bengston
Streamline Studio, LLC
www.streamline-studio.com

On Aug 19, 2013, at 4:57 PM, Bob Patin <bob at patin.com> wrote:

> Worked like a charm... thanks,
> 
> BP
> 
> Bob Patin
> Longterm Solutions LLC
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
> FileMaker 9, 10, 11& 12 Certified Developer
> Member of FileMaker Business Alliance and FileMaker TechNet
> --
> Twitter: bobpatin
> AIM: longterm1954
> iChat: bobpatin
> --
> Expert FileMaker Consulting 
> FileMaker Hosting for all versions of FileMaker
> 
> On Aug 19, 2013, at 4:54 PM, "Fitzgerald, Theodore C" <ted-fitzgerald at uiowa.edu> wrote:
> 
>> The pipe character is a special character in regex.  You'll probably need to escape it.  
>> 
>> This should work:
>> 
>> document.write(str.search("\\|"));
>> 
>> Ted
>> 
>> -----Original Message-----
>> From: fx.php_list-bounces at mail.iviking.org [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Bob Patin
>> Sent: Monday, August 19, 2013 4:42 PM
>> To: FX.php Discussion List
>> Subject: [FX.php List] Javascript question
>> 
>> OK, Javascript experts, splain this to me:
>> 
>> If I put this:
>> 
>> var str="2014#Steven Patin";
>> document.write(str.search("#"));
>> 
>> I get 4, which is what I would expect; now, if I put this:
>> 
>> var str="2014|Steven Patin";
>> document.write(str.search("|"));
>> 
>> I get 0.
>> 
>> Why?
>> 
>> Is a pipe not allowed? I'm trying to concatenate an ID and a name together and them parse them back out in JS, and the 2nd example fails. Stumped as to why...
>> 
>> Thanks,
>> 
>> Bob Patin
>> Longterm Solutions LLC
>> bob at longtermsolutions.com
>> 615-333-6858
>> http://www.longtermsolutions.com
>> FileMaker 9, 10, 11& 12 Certified Developer Member of FileMaker Business Alliance and FileMaker TechNet
>> --
>> Twitter: bobpatin
>> AIM: longterm1954
>> iChat: bobpatin
>> --
>> Expert FileMaker Consulting
>> FileMaker Hosting for all versions of FileMaker
>> 
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list