OneCompiler

digits

121
<?php //Establi shconnectiontoPostgreSQLdatabase $conn=pg_connect(“host=l ocalhostdbname=your_database_nameuser=your_username password=your_password”); //Checkifconnectionwassuccessful If(!$conn){ Echo“Connectionfail ed.”; Exit; } //Createstudenttabl e $query=“CREATETABLEstudent( RollnoINTEGERPRIMARYKEY, NameVARCHAR(50)NOTNULL, ClassVARCHAR(10)NOTNULL )”; $result=pg_query($conn,$query); If(!$resul t){ Echo“Errorcreati Exit; }else{ ngtable:“.pg_last_error($conn); Echo“Tablecreatedsuccessful } //Insert5recordsi ly.<br>”; ntostudenttable $insert_query=“I NSERTINTOstudent(rollno,name,class) VALUES(1,‘JohnDoe’,‘ 10A’), (2,‘JaneSmith’ ,‘9B’ ), (3,‘BobJohnson’ ,‘11C’ (4,‘SarahLee’ ,‘12D’ ), (5,‘TomBrown’,‘ ), 8E’)”; $insert_resul t=pg_query($conn,$insert_query); If(!$i nsert_resul t){ Echo“Errorinserti Exit; }else{ ngrecords:“.pg_last_error($conn); Echo“Recordsinsertedsuccessful ly.”; } //Closedatabaseconnection Pg_close($conn); //functi ontodisplaydatabaserecords Functiondispl ay_records($tabl //establi e_name){ shconnectiontoPostgreSQLdatabase $conn=pg_connect(“host=l ocalhostdbname=your_database_nameuser=your_username password=your_password”); //checkifconnecti onwassuccessful If(!$conn){ Echo“Connectionfail ed.”; Exit; } //retri everecordsfromspecifi edtable $query=“SELECT*FROM“.$table_name; $result=pg_query($conn,$query); //checkifquerywassuccessful If(!$resul t){ Echo“Errorretri Exit; } evingrecords:“.pg_l //displayrecordsi nanHTMLtable Echo“<table>”; Echo“<tr><th>Rol ast_error($conn); lNo</th><th>Name</th><th>Cl *****</th></tr>”; While($row=pg_fetch_assoc($resul t)){ Echo“<tr><td>”.$row[‘ roll no’].“</td><td>”.$row[ “</td></tr>”; } Echo“</table>”; //closedatabaseconnecti Pg_close($conn); } ?>

Importre
Text=“Hello,#world123!Thisisasampletextparagraph.Itcontai
nsspecialcharactersand5 digits."
#Removespecialcharactersanddigits
Processed_text=re.sub(r’
[^a-zA-Z\s]
’,‘
Print(processed_text