How to convert text with things like %C3%A0 - html

I have many list of names with things like %C3%A0 which I believe stands for a with an apostrophe.
M%C3%A0rius Torres should be Marius Torres.
But the problems is that there are many different kinds of these and I cannot change them manually anymore. There are about 13,000 unique names.
How can I convert it into their correct names in excel?
As a reference, I queried many names in wikipedia database. Here is the link

The names have most likely been URL encoded. This is done to anything that is included in an URL. For example, if I try to search for " it's " on Google, my browser goes to the address https://www.google.com.au/search?hl=en&q=it%27s. As you can see, the " it's " has been changed to " it%27s ".
All that you need to do in PHP to undo this is to put the string through the urldecode() function. You'd do the following:
$string = "M%C3%A0rius Torres";
$decoded = urldecode($string);
echo $decoded;
That should give you the decoded string. Read more about the urldecode() function at http://au1.php.net/urldecode.

Your text is URL encoded. Since you have php as one of your tags, I'm assuming the output goes through some form of PHP processing. In that case, you'll want to use the urldecode function. Documentation can be found here.

In Excel, like Word, you should be able to use "find"/"find & select" followed by "replace".
You can also "sort and filter" to group things.
Both in top right hand corner of the Home page in Excel.

Related

Adding new field to each JSON Object

I am currently doing a project and I have a huge json list with schools in my country I would like to add one more field to each object, is there any website to do this, without typing it manually?
There are many ways you can achieve this.
First, I am assuming you are dealing with what is known as a json array which looks like this
[{name:"John", age:31, city:"New York"},
{name:"Jim", age:27, city:"London"},
{name:"Jeff", age:80, city:"Dublin"}]
You could simply use a program such as Notepad++ & do a search/replace Ctrl+h.
Find what: }
Replace with: , mynewfield: ""}
This method will replace all instances of an ending curly bracket (end of a json object) with a new field & value of your choice. So essentially, its just appending a new field for each object.
An alternative way that is also very useful when dealing with large data is with "regular expressions" (or regex expressions). The use case here for using a regex expression could be if you didn't want to add your new field to the end of each object but, somewhere in the middle (like before/after age).
In the case, you could use
Find what: (?<=,)(.*)(?=age) (or (?<=,)(.*)(?=city))
Replace with: mynewfield: "",
NOTE: For regex expressions you must have them enabled under the "Search Mode" after clicking control+h.

Regex To Exclude Email-Expression

I have 430 HTML files of different organization's contact us web pages, I was given this files to extract emails from.
This regex simple code I came up with detects and finds emails throughout the files
\S*#\S*
My Problem
I'm trying to select everything besides the emails so I can use Notepad++'s "Replace All in All Opened Documents" function to delete everything besides the emails. Is this possible with regular expressions?
Is there anyway I can select everything outside of the regular expression provided above?
Make sure you have a recent version of Notepad++ installed to have the necessary regex support:
Find what : (^|\s+)[^#]+(\s+|$)
Replace with : \n
🔘 Regular expression
The . matches newline option does not influence the action.
You need to remove all text that does not match some pattern.
You need to match and capture the emails with a (...) capture group and then you need to just match everything else.
Use a pattern like this: ( + your_pattern + )|., and replace with $1.
Or, use:
([^\s<>"]+#[^\s<>"]+)|.
or
(\b[A-Za-z0-9._%+-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b)|.
Replace with: $1
Then, you might want to use Edit -> Blank Operations -> Remove Unnecessary Blank and EOL menu option.

Display image with wildcard in src

I have a series of photos on a server with a strict naming convention: "uniqueId-readableName.jpg". I do this because my website database currently only logs the uniqueID (and some unrelated info), but people occasionally need to look at the file server directly to browse the photos (via FTP) so a readable name is useful. For example
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
129084-Laboring at the farm 2013-08-11.jpg
Now, I'm fairly sure the best option would be to set up the database with a record of the full file names, but I just wanted to see if anyone had any ideas I may have missed. This question on SO is similar, but here I have strict naming conventions - not sure if that opens up any possibilities or not.
I'm applying this to img, but the same idea could be appled to any file extension (eg, download "789-My Homework.zip" or "123-Family vacation.zip").
As an example of what I'm looking for, in Windows Explorer you can do a file search for
0*.jpg
and all of the following files can be returned
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
029084-Laboring at the farm 2013-08-11.jpg
In my case the beginning part is always unique, so I'd like to use something like 001456-*.jpg and have it return 001456-War Horse.jpg.
Is there any way do this on a website?
<img src="001456-*.jpg" />
Although no such method exists, you can still do a server side scripting to acheive the functionality you require.
For example in PHP you could use in-built commands to browse a folder, select all files matching the criteria name as '001456-*.jpg' and then depending upon the number of records returned select the first filename and insert it into an IMG tag.
Here is a sample implementation in PHP:
$files = array();
$id = "001456";
$files = glob("id-*.jpg");
echo "<img src='$files[0]' />"; //Assuming one file is found for every unique ID.

Query strings with HTTP URL

I am trying to do a HTTP GET of an URL with multiple query strings using a browser. Following is my observation
http://192.168.0.1:80/mycontent/?key1=value1 //Works.
http://192.168.0.1:80/mycontent/?key1=value1&key2=value2 //Doesen't work.
The question here :
I am finding a hard time to figure out what's the right format to
append the query string
Should we use &amp when we put in the browser?
Is there a way that I can find the validity (availability in the server) of the query string I enter in the URL.
You should use & when writing the link into HTML, for example:
Example
But not when entering the URL into the address bar, or using it directly in JavaScript (for example).
Your format is correct, so you should be able to pick up both key1 and key2 in the request collection. Depending on the language you are using on the server, the technique for this differs.

separating values in a URL, not with an &

Each parameter in a URL can have multiple values. How can I separate them? Here's an example:
http://www.example.com/search?queries=cars,phones
So I want to search for 2 different things: cars and phones (this is just a contrived example). The problem is the separator, a comma. A user could enter a comma in the search form as part of their query and then this would get screwed up. I could have 2 separate URL parameters:
http://www.example.com/login?name1=harry&name2=bob
There's no real problem there, in fact I think this is how URLs were designed to handle this situation. But I can't use it in my particular situation. Requires a separate long post to say why... I need to simply separate the values.
My question is basically, is there a URL encodable character or value that can't possibly be entered in a form (textarea or input) which I can use as a separator? Like a null character? Or a non-visible character?
UPDATE: thank you all for your very quick responses. I should've listed the same parameter name example too, but order matters in my case so that wasn't an option either. We solved this by using a %00 URL encoded character (UTF-8 \u0000) as a value separator.
The standard approach to this is to use the same key name twice.
http://www.example.com/search?queries=cars&queries=phones
Most form libraries will allow you to access it as an array automatically. (If you are using PHP (and making use of $_POST/GET and not reinventing the wheel) you will need to change the name to queries[].)
You can give them each the same parameter name.
http://www.example.com/search?query=cars&query=phones
The average server side HTTP API is able to obtain them as an array. As per your question history, you're using JSP/Servlet, so you can use HttpServletRequest#getParameterValues() for this.
String[] queries = request.getParameterValues("query");
Just URL-encode the user input so that their commas become %2C.
Come up with your own separator that is unlikely to get entered in a query. Two underscores '__' for example.
Why not just do something like "||"? Anyone who types that into a search area probably fell asleep on their keyboard :} Then just explode it on the backend.
easiest thing to do would be to use a custom separator like [!!ValSep!!].