Arnab Chakraborty

Arnab Chakraborty

29 Articles Published

Articles by Arnab Chakraborty

29 articles

Java regex to exclude a specific String constant

Arnab Chakraborty
Arnab Chakraborty
Updated on 29-Sep-2024 2K+ Views

In this program, we will use a regular expression to check if a given string does not contain the substring "kk" using Java. The regular expression ^((?!kk).)*$ is designed to match strings that do not include the "kk" pattern anywhere in the string. The program will evaluate a sample string and print whether or not it contains "kk". Problem Statement Write a program in Java for checking whether a given string contains the substring "kk." If the string does not contain "kk" the program will return true otherwise it will return false. Input String s = "tutorials" Output true ...

Read More

How to validate a form using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 09-Sep-2023 32K+ Views

At first you have to make a html form like. Validation of a form First name: Last name: Email: Now use jQuery validation plugin to validate forms' data in easier way.first, add jQuery library in your file. then add javascript code: $(document).ready(function() {    $("#form").validate(); }); Then to define rules use simple syntax.jQuery(document).ready(function() {    jQuery("#forms).validate({       rules: {          firstname: 'required',          lastname: 'required',          u_email: {             required: true,   ...

Read More

How to process a simple form data using Python CGI script?

Arnab Chakraborty
Arnab Chakraborty
Updated on 09-Sep-2023 4K+ Views

Suppose there is an HTML file as below − FirstName: LastName: After submitting this form it should go to a Python page named "getData.py", where you should fetch the data from this HTML page and show. then below is the code for Python CGI. #!C:\Python27\python.exe # Import modules for CGI handling import cgi, cgitb # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields first_name = form.getvalue('first_name') last_name  = form.getvalue('last_name') print("Content-type:text/html") print print("") print("") print("Hello - Second CGI Program") print("") print("") print(" ...

Read More

How can I remove all child elements of a DOM node in JavaScript?

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Aug-2022 14K+ Views

Suppose you are building a web app that manages the data of daily tasks, the user inserts the task and a list of tasks gets formed. But at some point in time, the user wants to remove all the tasks from the list and wants to make the list empty. So, as a developer, you should know how to remove all the child elements from the DOM node. To remove all the elements from the DOM node we have the following approaches. By iterating the DOM nodes and using the removeChild method. By Erasing the innerHTML value to a ...

Read More

How to horizontally center a <div> in another <div>?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Dec-2021 349 Views

Here I have one html form and one css file(style.css).”o-div” is the outer div and “i-div“is the inner div class.Example           center a div                              I am OUTER DIV                       I am INNER DIV,             I am in Center                     OutputI am OUTER DIV I am INNER DIV, I am in CenterStyle.cssbody {    background-color:Gray;    padding:30px; } .o-div {    padding:50px;    background-color:Lime; } .i-div {    background-color:Fuchsia;    max-width:400px;    height:200px;    margin: 0 auto;    text-align:center; }

Read More

How to test if a Java String contains a case insensitive regex pattern

Arnab Chakraborty
Arnab Chakraborty
Updated on 24-Jun-2020 459 Views

the syntax? i:x makes the string search case-insensitive. for egpublic class RegCaseSense {    public static void main(String[] args) {       String stringSearch = "HI we are at java class.";       // this won't work because the pattern is in upper-case       System.out.println("Try this 1: " + stringSearch.matches(".*CLASS.*"));         // the magic (?i:X) syntax makes this search case-insensitive, so it returns true       System.out.println("Try this 2: " + stringSearch.matches("(?i:.*CLASS.*)"));    } }

Read More

Can someone help me fix this Python Program?

Arnab Chakraborty
Arnab Chakraborty
Updated on 24-Jun-2020 146 Views

The first problem u are getting in the bold portion is due to non-indent block, put one indentation there.second problem is name variable is not definedfollowing is the corrected one -print ("Come-on in. Need help with any bags?") bag=input ('(1) Yes please  (2) Nah, thanks   (3) Ill get em later  TYPE THE NUMBER ONLY') if bag == ('1'): print ("Ok, ill be right there!") if bag == ('2'): print ("Okee, see ya inside. Heh, how rude of me? I'm Daniel by the way, ya?") name="Daniel" print (name + ": Um, Names " + name) print ("Dan: K, nice too ...

Read More

How to use enums in Python classes?

Arnab Chakraborty
Arnab Chakraborty
Updated on 23-Jun-2020 315 Views

There is a module name "enum" in python with the hep of which enum is used in python.#import enum import enum # use enum in class class Car(enum.Enum):    suzuki = 1    Hyundai = 2    Dezire = 3 print ("All the enum values are : ") for c in (Car):    print(c)

Read More

Match all occurrences of a regex in Java

Arnab Chakraborty
Arnab Chakraborty
Updated on 23-Jun-2020 313 Views

public class RegexOccur {    public static void main(String args[]) {       String str = "java is fun so learn java";       String findStr = "java";       int lastIndex = 0;       int count = 0;       while(lastIndex != -1) {          lastIndex = str.indexOf(findStr,lastIndex);          if(lastIndex != -1) {             count ++;             lastIndex += findStr.length();          }       }       System.out.println(count);    } }Output2

Read More

How to send the result of Python CGI script to the browser?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Jun-2020 337 Views

# Get data from fields from HTML page first_name = form.getvalue('first_name') last_name  = form.getvalue('last_name') send data to Browser print("Content-type:text/html") print print("") print("") print("Hello - Second CGI Program") print("") print("") print(" Hello %s %s " % (first_name, last_name)) print("") print("")

Read More
Showing 1–10 of 29 articles
« Prev 1 2 3 Next »
Advertisements