Tag Archives: string

Rewrite query string in .htaccess

Questions: I’m trying to do a very simple rewrite of a query string and I’m having no luck at all. I need to go from http:// example dot com/?ACT=jquery to http:// example dot com/index.php?ACT=jquery This is the code that I’ve written in my .htaccess file and it throws me an internal server error. I’m really… Read More »

Java Apache FileUtils readFileToString and writeStringToFile problems

Questions: I need to parse a java file (actually a .pdf) to an String and go back to a file. Between those process I’ll apply some patches to the given string, but this is not important in this case. I’ve developed the following JUnit test case: String f1String=FileUtils.readFileToString(f1); File temp=File.createTempFile(“deleteme”, “deleteme”); FileUtils.writeStringToFile(temp, f1String); assertTrue(FileUtils.contentEquals(f1, temp));… Read More »

htaccess redirect URL using partial value of string parameter

Questions: I have a bunch of products listed at https://www.example.com/all/products/foldername/1234567890-ProductDescriptionA-456.html https://www.example.com/all/products/foldername/7654321-SomeOtherDesc-B123.html https://www.example.com/all/products/foldername/93939393-anotherthing-F93939393.html and I want these to be redirected to https://www.example.com/products.php?p=1234567890 https://www.example.com/products.php?p=7654321 https://www.example.com/products.php?p=93939393 respectively. Is there an htaccess rule to do string operations on a matched parameter? For example, if I had to convert my URL using Python, it would look like this: def make_new_url(old_url):… Read More »

PHP htaccess Redirect url with query string from uppercase to lowercase

Questions: I have this small php script and couple lines in htaccess to redirect urls with query strings from uppercase to lowercase. However, it redirects uppercase characters in query string to lowercase ones only if there is an uppercase character in the url file or directory part of the url. Example with uppercase directory: domain.com/JOBS/?position=Java+Developer… Read More »

AJAX: Check if a string is JSON?

Questions: My JavaScript sometimes crashes on this line: var json = eval(‘(‘ + this.responseText + ‘)’); Crashes are caused when the argument of eval() is not JSON. Is there any way to check if the string is JSON before making this call? I don’t want to use a framework – is there any way to… Read More »

jQuery send string as POST parameters

Questions: I want to send a string as an ajax Post parameter. The following code: $.ajax({ type: “POST”, url: “http://nakolesah.ru/”, data: ‘foo=bar&ca$libri=no$libri’, success: function(msg){ alert(‘wow’+msg); } }); Is not working. Why? Answers: Try like this: $.ajax({ type: ‘POST’, // make sure you respect the same origin policy with this url: // http://en.wikipedia.org/wiki/Same_origin_policy url: ‘http://nakolesah.ru/’, data:… Read More »

Find text string in jQuery and make it bold

Questions: What I want to do is use jQuery to find a piece of text within a paragraph and add some CSS to make it bold. I can’t seem to figure out why this won’t work: $(window).load(function() { // ADD BOLD ELEMENTS $(‘#about_theresidency:contains(“cross genre”)’).css({‘font-weight’:’bold’}); }); The text in “about_theresidency” is dynamically pulled in, hence me… Read More »

Converting an XML file to string type

Questions: How can we write an XML file into a string variable? Here is the code I have,the variable content is supposed to return an XML string: public string GetValues2() { string content = “”; XmlTextWriter textWriter = new XmlTextWriter(content, null); textWriter.WriteStartElement(“Student”); textWriter.WriteStartElement(“r”, “RECORD”, “urn:record”); textWriter.WriteStartElement(“Name”, “”); textWriter.WriteString(“Student”); textWriter.WriteEndElement(); textWriter.Close(); return contents; } Answers: Something… Read More »