Regular expressions

Some handy regular expressions terms

If you want to remove only specific tags from the html, you can use following regular expression. I use it along with PHP storm.

For example here is my sample code

    <a href="/samplelink/5656/565">
        <i class="fa fa-trash-o fa-2x" aria-hidden="true"></i>
    <a href="/samplelink/21112/21">
        <i class="fa fa-trash-o fa-2x" aria-hidden="true"></i>
    <a href="/samplelink/99/997"> 
        <i class="fa fa-trash-o fa-2x" aria-hidden="true"></i>

if you want to replace all a tags

<a href="/samplelink/99/997">

I will use the following code in regular expressions to find

<a href=".*?"\s*[/>]* 


Reading a .sql file for sqlite database


I am developing an andriod app and I have my data in .sql file downloaded via phpmyadmin.

Now there are some format difference in sql and sqlite3 commands. so I have performed the following steps to read the file in the format that is understandable by sqlite3 database

however make sure when you download the sql file from phpmyadmin, it should be MAXDB sql compatiblity mode. I have tested this, however it should also work on ANSI and DB2 compatiblity mode, but I have not used that
Also the settings shown in the image should be there when downloading the sql file


Here is the code which I used to read the sql file and populate it in sqlite3 database

private void fillData() {
DbHelper dh = new DbHelper(this);
SQLiteDatabase d = dh.getWritableDatabase();
String line;
String incompleteLine="";

try {
InputStream in = this.getAssets().open(“data.sql”);
if (in != null) {
// prepare the file for reading
InputStreamReader input = new InputStreamReader(in);
BufferedReader buffreader = new BufferedReader(input);

while ((line = buffreader.readLine()) != null) {
// Toast.makeText(this, line,Toast.LENGTH_LONG).show();
// d.execSQL(“INSERT INTO brand (_id,name,info) VALUES (‘2′,’AMICA’,’amica’);”);
// Print the content on the console
if (line.indexOf(“-“)==0 || line.indexOf(“/”)==0 || line.indexOf(“SET”)==0)

if (line.contains(“;”))
System.out.println (incompleteLine);


// Toast.makeText(this, res, Toast.LENGTH_LONG).show();
} else {
} catch (Exception e) {
Toast.makeText(this, e.toString() + e.getMessage(), 50000000).show();


Intent selectBrandIntent = new Intent(this, SelectBrand.class);