Jump to content

Issues with spaces


Recommended Posts

Thanks to Dave earlier, I got my script working.

 

However I've been debugging a problem for a while and haven't been able to come up with a solution.

 

The issues seems to be with my script that any spaces seem to kill the script and default back to Google/Amazon/Wiki search.

 

To test it wasn't my code, I've done the following example lines:

 

$filter = preg_split("/\s/", trim("web 1"));

$filter = preg_split("/\s/", trim(str_replace('-', ' ', "{query}")));

 

In the first case, I run the PHP script from the command line and it works fine.  In the second one, when I need to put a space in I instead do a dash (so I can do'web-1' or '1-web') and in both cases it works fine.  But try 'web 1' in Alfred, and it breaks after I do 'web' then space.

 

I was just exploding on the space as well in previous versions, but had no luck getting this to work.

 

Any ideas?

 

(Oh I should say this is a PHP script)

Edited by tanepiper
Link to comment

Thanks to Dave earlier, I got my script working.

 

However I've been debugging a problem for a while and haven't been able to come up with a solution.

 

The issues seems to be with my script that any spaces seem to kill the script and default back to Google/Amazon/Wiki search.

 

To test it wasn't my code, I've done the following example lines:

 

$filter = preg_split("/\s/", trim("web 1"));

$filter = preg_split("/\s/", trim(str_replace('-', ' ', "{query}")));

 

In the first case, I run the PHP script from the command line and it works fine.  In the second one, when I need to put a space in I instead do a dash (so I can do'web-1' or '1-web') and in both cases it works fine.  But try 'web 1' in Alfred, and it breaks after I do 'web' then space.

 

I was just exploding on the space as well in previous versions, but had no luck getting this to work.

 

Any ideas?

 

(Oh I should say this is a PHP script)

 

Any way that you could share it with me or let me take a peak at some of the code? I could probably find a solution a lot faster that way

Link to comment
  • 2 months later...

Any word on how to fix this? I am experiencing the same issue with spaces killing the script.

 

EDIT: FIXED

 

I got mine working by declaring the variable earlier then using the variable in the script:

 

 

$the_query = "{query}";
 
echo '<?xml version="1.0"?>
<items>
  <item uid="NA" valid="no">
    <title>'.strlen($the_query).'</title>
    <subtitle>"'.$the_query.'"</subtitle>
    <icon>D9AAD7B8-26CC-4444-B8D0-35F833CC0C05.png</icon>
  </item>
</items>';
Edited by johncox
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...