Within the API for smartsheet I use the search everything method.
Already solved in cUrl (check Special characters in Smartsheet API (2.0) - search), but within C-sharp how can I solve this:
When trying to search for 'A01 PXXX' it returns me also rows (and cells) which contain only 'A01' and 'PXXX'. Is there a way to search for the whole searchstring (so including the space character). Unicode "\u0020" or "%20" do not seem to work. Anyone ?
Did you try putting the whole search string in double quotes(i.e. "\"A01 PXXX\"")?
Related
I wanted to verify a text in a webpage exist for 2 times or ‘n’ times. I have used “Page Should Contain” keyword but it says “Pass” when it identifies single occurrence. I don’t want to verify using locator.
Ex: I want to verify the text "Success" is available in a current webpage for 3 times using robot framework
Any inputs/suggesstions would be helpful.
Too bad you don't want to use a locator, as robotframework has a keyword just for that:
Xpath Should Match X Times //*[contains(., "Success")] 2
The caveat is the locator should not be prepended with xpath= - just straight expression.
The library keyword Page Should Contain does pretty much exactly that, by the way.
And if you want to find how many times the string is present in the page - easy:
${count}= Get Matching Xpath Count //*[contains(., "Success")]
And then do any kind of checks on the result, e.g.
Should Be Equal ${count} 2
I thought the problem of not using locator sounds fun (the rationale behind the requirement still unclear, yet), so another solution - look in the source yourself:
${source}= Page Source # you have the whole html of the page here
${matches}= Get Regexp Matches ${source} >.*\b(Success)\b.*<
${count}= Get Length ${matches}
The first one gets the source, the second gets all non-overlapping (separate) occurrences of the target string, when it is (hopefully) inside a tag. The third line returns the count.
Disclaimer - please don't actually do that, unless you're 100% sure of the source and the structure. Use a locator.
I've created an API for use on my website.
The API I made strips everything using mysql_real_escape_string then puts it into the database.
But the problem I'm having is the URL that my php scripts are using to access the API is cut short sometimes...
Which I have narrowed down to one of the parameters...
When its Ford Mondeo 22' the URL that is passed to simplexml_load_file is
http://mydomain.com/api/create.xml?api_number=brho15p6z1dhqwf5tsff&env=live&number=AJ20023232&title=Ford Mondeo 22'&image=http://mydomain.com/wp-content/uploads/2012/10/914955-150x150.jpg
but the API reports back the URL accessed as
http://mydomain.com/api/create.xml?api_number=brho15p6z1dhqwf5tsff&env=live&number=AJ20023232&title=Ford
If I remove the single quote then everything works fine, any idea how to correct this I suspect there's something I've overlooked when passing variables in the URL
It is the spaces in the "Ford Mondeo 22'" value that is causing the problem. You cannot have a spaces in the URL. You need to use escape characters. The encoded version of the parameter should be
Ford%20Mondeo%2022'
%20 is the escape character for space
I.e. the whole URL should read as follows:
http://mydomain.com/api/create.xml?api_number=brho15p6z1dhqwf5tsff&env=live&number=AJ20023232&title=Ford%20Mondeo%2022'&image=http://mydomain.com/wp-content/uploads/2012/10/914955-150x150.jpg
EDIT:
Your comment indicates that you use PHP. In PHP, you can use urlencode($foo) and urldecode($foo) to switch between the normal string and the encoding string.
I have never had practical success when using the search feature in Tridion (SDL Tridion 2011). I am looking at a list of components. I enter some of the text for one those component's name and the search does not find it. I have to use the exact name of the component for it to find it.
What fields does it search using my criteria?
Is there a wild card symbol I can use or a setting to make it a "contains" query?
The Search Indexer should index all fields of every components as well as text in binaries (PDFs, MS Word Docs etc). I have a running instance of SDL Tridion 2011 and can confirm that it does in fact give results from both binary and normal component content.
I am not entirely sure of the inner workings of the newer SolR version of Tridion, but I imagine that Titles and Full text are indexed separately.
It could be that your indexer is not actually running properly, I have seen the service appear to be in the running state, but not actually processing messages in the Search Queue. Try opening the Purge Queue tool (Normally located at "C:\Program Files (x86)\Tridion\bin\TcmPurgeQueue.exe"), and see if there are lots of messages waiting in the Search Queue. If there are, it may be that items are not being processed properly, try hitting refresh and see if the number is going down.
For a wildcard, you should just be able to use a '*'. I just tested putting the string "Rampusplong" in a component filed, and can confirm that searching for "Rampusplong" or "Rampus*" or "*ampusplo*" return my result, but "Rampus" returns no results.
Yes, * for wild cards as Chris mentions. See some reserved word options below (source: the SDL Welcome "Getting to Know SDL Tridion" help pages) for other options to try.
identifier (e.g. tcm:19-123-8)
search operators
AND
OR
NOT
IN (e.g. "someword IN title", where title is the component's XML)
exact phrases delimited with " (e.g. "Mad cookie")
wildcards
* for wildcard, multiple characters (I've sometimes needed this on supposed full matches)
? for single
special characters
+ - ! ( ) { } [ ] ^ " ~ * ? : \
(help file doesn't say much more except to escape with double quotes)
reserved words (escape with \ regardless of capitalization)
CONTAINS
NEAR
SENTENCE
PARAGRAPH
PHRASE
IN
MATCHES
STARTS
SUBSTRING
ENDS
AND
OR
NOT
You can also search in multimedia as well as metadata, schema, and the other visible search options by clicking on the advanced search (down arrow next to search).
At least in older versions (R5.3 specifically and possibly 2009), I've seen items outside of regular creation (via VBScript) skip getting indexed. Re-index if that's the case, but not sure with 2011.
I'm looking to do do two things, and I am looking to do them in a beautiful way. I am working on a project that allows users to upload flickr photos by simply entering their flickr image URL. Ex: http://www.flickr.com/photos/xdjio/226228060/
I need to:
make sure it is a URL that matches the following format: http://www.flickr.com/photos/[0]/[1]/
extract the following part: http://www.flickr.com/photos/xdjio/[0]/
Now I could very easily write some string methods to do the above but I think it would be messy and love learning how to do these things in regex. Although not being a regex ninja I am currently unable to do the above.
Given an input string with a URL like the one you provided, this will extract the image ID for any arbitrary user:
string input = "http://www.flickr.com/photos/xdjio/226228060/";
Match match = Regex.Match(input, "photos/[^/]+/(?<img>[0-9]+)", RegexOptions.IgnoreCase | RegexOptions.SingleLine);
if(match.Success)
{
string imageID = match.Groups["img"].Value;
}
Breaking it down, we are searching for "photos/" followed by one or more characters that is not a '/', followed by a /, followed by one or more characters that are numbers. We also put the numbers segment into a named group called "img".
thought i would add to this that when using the javascript asp.net validator it doesn't support the grouping name.
the regex to use in this situation would be:
photos/[^/]+/([0-9]+)
thought someone might find this useful
I have a query string parameter value that contains an ampersand. For example, a valid value for the parameter may be:
a & b
When I generate the URL that contains the parameter, I'm using System.Web.HTTPUtility.UrlEncode() to make each element URL-friendly. It's (correctly) giving me a URL like:
http://example.com/foo?bar=a+%26b
The problem is that ASP.NET's Request object is interpreting the (encoded) ampersand as a Query String parameter delimiter, and is thus splitting my value into 2 parts (the first has "bar" as the parameter name; the second has a null name).
It appears that ASP.NET is URL-decoding the URL first and then using that when parsing the query string.
What's the best way to work around this?
UPDATE: The problem hinges on URLRewriter (a third-party plugin) and not ASP.NET itself. I've changed the title to reflect this, but I'll leave the rest of the question text as-is until I find out more about the problem.
man,
i am with you in the same boat, i have spent like hours and hours trying to figure out what is the problem, and as you said it is a bug in both, as normal links that contain weird characters or UTF-8 code characters are parsed fine by asp.net.
i think we have to switch to MVC.routing
Update: man you wont believe it, i have found the problem it is so strange, it is with IIS,
try to launch your page from visual studio Dev server and Unicode characters will be parsed just fine, but if you launch the page from IIS 7 it will give you the ???? characters.
hope some body will shade some light here
I would have thought that %26 and '&' mean exactly the same thing to the web server, so its the expected behavior. Urlencode is for encoding URLs, not encoding query strings.
... hang on ...
Try searching for abc&def in google, you'll get:
http://www.google.com.au/search?q=abc%26def
So your query string is correct, %26 is a literal ampersand. Hmm you're right, sounds like a bug. How do you go with an & instead of the %26 ?
Interesting reading:
http://www.stylusstudio.com/xsllist/200104/post11060.html
Switching to UrlRewritingNet.UrlRewrite did not help, as it apparently has the same bug. I'm thinking it might have something to do with ASP.NET after all.
I think URLRewriter has a problem with nameless parameters (null name).
I had a similar problem. When I gave my nameless parameter a (dummy) name, everything worked as expected.