Arnab Chakraborty has Published 34 Articles

How to get current URL in JavaScript?

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jun-2020 14:20:51

444 Views

The window.location object can be used to get the current URL.window.location.href returns the href(URL) of the current page.I am using these code in my MVC projet.Example                                          var iid=document.getElementById("dd");         alert(window.location.href);       iid.innerHTML = "URL is" + window.location.href;    

Why we should use whole string in Java regular expression

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jun-2020 14:14:42

851 Views

In Java regex matches() matches the input string against the whole string as it add a ^ and $ at the end of the input string.so it will not match the substring. So for matching substring, you should use find().Exampleimport java.util.regex.*; class PatternMatchingExample {    public static void main(String args[]) ... Read More

Regex to match lines containing multiple strings in Java

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jun-2020 06:33:07

593 Views

ExampleLive Demoimport java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SearchRegex {    private Pattern subPattern = Pattern.compile(SUBJECT_PATTERN);    private Matcher matcher;    private static final String SUBJECT_PATTERN = "(?s)Subject 1:\s(.*)Subject 2:";    public static void main(String[] args) {       String d = ... Read More

How to match a line not containing a word in Java Regex

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jun-2020 06:31:20

261 Views

ExampleLive Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class NoRegTest {    public static void main(String[] args) {       String s="^fun";       Pattern pattern = Pattern.compile(s);       Matcher matcher = pattern.matcher("Java is fun");       if(!matcher.find()) {          System.out.println("not found");       }    } }Outputnot found

How to extract a group from a Java String that contains a Regex pattern

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jun-2020 06:30:13

223 Views

How to extract a group from a Java String that contains a Regex patternimport java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexTest {    public static void main(String[] args) {       Pattern pattern = Pattern.compile("fun");       Matcher matcher = pattern.matcher("Java is fun");       // ... Read More

How can I write in order with for loop or while loop?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 15:34:17

155 Views

Example#include #include void main() {    int i,j,a=0,b=1,n;    clrscr();    printf("****************OUTPUT*****************");    printf("enter the value of n : ");    scanf("%d",&n);    printf(" the required order is: " );    for(i=1;i

How to capture multiple matches in the same line in Java regex

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 10:49:20

2K+ Views

Exampleimport java.util.regex.*; class PatternMatcher {    public static void main(String args[]) {       int count = 0;       // String to be scanned to find the pattern.       String content = "aaa bb aaa";       String string = "aaa";     ... Read More

Java Regular Expression that doesn't contain a certain String.

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 10:34:58

454 Views

Exampleimport java.util.regex.*; class PatternMatch{    public static void main(String args[]) {       String content = "I am a student";       String string = ".*boy.*";       boolean isMatch = Pattern.matches(string, content);       System.out.println("The line contains 'boy'?"+ isMatch);    } }Outputthe line contains 'boy'?falsematches()­­It ... Read More

Operating system time slicing in round robin scheduling

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Jun-2020 09:50:34

202 Views

process Burst time A 4 B 1 C 8 D 1time slice=10 unitA B C D A C C C 0 2 3 5 6 8 10 12 14So A will complete 8 cycles.

Reply to user text using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Jun-2020 08:28:13

2K+ Views

You can solve this problem by using if-elif-else statements. And to make it like, it will ask for a valid option until the given option is on the list, we can use while loops. When the option is valid, then break the loop, otherwise, it will ask for the input ... Read More

Advertisements