Regular Expressions (Regex) is powerful and convenient to use for string manipulation i.e. matching and validation, extracting and capturing, modifying and substitution, etc. This presentation covers Regular Expression with real world examples and demos.
Array Basics
Copying Arrays
Passing Arrays to Methods
Returning an Array from a Method
(Optional) Variable-Length Argument Lists
The Arrays Class
Two-Dimensional Arrays
(Optional) Multidimensional Arrays
This document discusses arrays in Java. It defines an array as a fixed-size collection of elements of the same type that can store a collection of data. It describes how arrays allow storing multiple variables of the same type at once. The document covers declaring, constructing, initializing single and multi-dimensional arrays, and gives an example of how arrays can solve the problem of needing to store exam scores for 100 students.
An Introduction to Programming in Java: ArraysMartin Chapman
An Introduction to Programming in Java: Arrays. Last delivered in 2012. All educational material listed or linked to on these pages in relation to King's College London may be provided for reference only, and therefore does not necessarily reflect the current course content.
An array allows you to store multiple values of the same type. It is like a spreadsheet with columns. You specify the data type of the array and the number of elements (size). Each element has an index position starting from 0. You can assign values to each position using arrayName[index] = value. Arrays make it easy to work with multiple values of the same type.
This document discusses arrays in Java programming. It covers defining and creating single and multi-dimensional arrays, accessing array elements using indexes and loops, and performing operations like sorting and finding maximum/minimum values. Examples are provided for different array types like integer, string and character arrays, and operations like input/output, break/continue statements, and star patterns. Homework involves writing a program to produce a given output pattern.
The document discusses Java arrays. It explains that arrays allow storing a fixed number of elements of the same type. Arrays are declared with a variable name and type, and individual elements accessed via indices. Arrays are created using new and assigned a size. Elements can be accessed, iterated over using for/foreach loops, passed to methods, and operated on using utility methods in the Arrays class like sort, binarySearch, fill.
This document discusses arrays in C programming. It defines arrays as ordered lists of homogeneous data elements stored in consecutive memory locations that can be accessed via indices. Arrays are classified as one-dimensional or multi-dimensional based on the number of indices. One-dimensional arrays are linear lists that can be declared with a size and data type. Multi-dimensional arrays have more than one index and can be two-dimensional like a matrix with rows and columns. Examples of declaring and using one and two-dimensional arrays in C code are provided.
Array Basics
Copying Arrays
Passing Arrays to Methods
Returning an Array from a Method
(Optional) Variable-Length Argument Lists
The Arrays Class
Two-Dimensional Arrays
(Optional) Multidimensional Arrays
This document discusses arrays in Java. It defines an array as a fixed-size collection of elements of the same type that can store a collection of data. It describes how arrays allow storing multiple variables of the same type at once. The document covers declaring, constructing, initializing single and multi-dimensional arrays, and gives an example of how arrays can solve the problem of needing to store exam scores for 100 students.
An Introduction to Programming in Java: ArraysMartin Chapman
An Introduction to Programming in Java: Arrays. Last delivered in 2012. All educational material listed or linked to on these pages in relation to King's College London may be provided for reference only, and therefore does not necessarily reflect the current course content.
An array allows you to store multiple values of the same type. It is like a spreadsheet with columns. You specify the data type of the array and the number of elements (size). Each element has an index position starting from 0. You can assign values to each position using arrayName[index] = value. Arrays make it easy to work with multiple values of the same type.
This document discusses arrays in Java programming. It covers defining and creating single and multi-dimensional arrays, accessing array elements using indexes and loops, and performing operations like sorting and finding maximum/minimum values. Examples are provided for different array types like integer, string and character arrays, and operations like input/output, break/continue statements, and star patterns. Homework involves writing a program to produce a given output pattern.
The document discusses Java arrays. It explains that arrays allow storing a fixed number of elements of the same type. Arrays are declared with a variable name and type, and individual elements accessed via indices. Arrays are created using new and assigned a size. Elements can be accessed, iterated over using for/foreach loops, passed to methods, and operated on using utility methods in the Arrays class like sort, binarySearch, fill.
This document discusses arrays in C programming. It defines arrays as ordered lists of homogeneous data elements stored in consecutive memory locations that can be accessed via indices. Arrays are classified as one-dimensional or multi-dimensional based on the number of indices. One-dimensional arrays are linear lists that can be declared with a size and data type. Multi-dimensional arrays have more than one index and can be two-dimensional like a matrix with rows and columns. Examples of declaring and using one and two-dimensional arrays in C code are provided.
Arrays are a data structure that allow the storage of multiple elements of the same type. They can have one or more dimensions. One-dimensional arrays use a single subscript, while two-dimensional arrays use two subscripts to reference rows and columns. Arrays can be passed as arguments to functions in several ways, including as a pointer, sized array, or unsized array. Arrays are useful for storing and sorting data, performing matrix operations, and storing temporary values in recursive functions. However, arrays have limitations such as a static size, requiring elements to be of the same type, and potential memory issues if not sized correctly.
This document discusses arrays in Java. It begins with an introduction to arrays as fixed-length data structures that hold multiple elements of the same type. The document then covers declaring and creating arrays, initializing arrays, and examples of using arrays, including summing array elements, displaying arrays in histograms, and analyzing survey results by storing responses in an array. The document also discusses passing arrays to methods by reference, meaning any changes made to the array in the method also change the original array. It provides an example program that passes an array to a method that directly modifies the array elements, as well as passing an array element by value so the method only modifies a copy of the primitive value.
Arrays allow for the storage of multiple values of the same data type in contiguous memory locations that can be accessed via indexes. In Java, arrays are objects that hold a collection of similar type elements. Arrays are declared with a type followed by empty brackets, and initialized using the new keyword along with the size of the array. Multidimensional arrays are arrays of arrays, allowing the use of multiple subscript operators to access elements.
An array is a sequential collection of data storage locations of the same type. Each storage location is called an element of the array. Arrays are collections of variables of the same type that are referred to through a common name, with each variable possessing a unique number called a subscript. Individual members of an array are called elements of the array. An array is declared by specifying the type followed by the array name and the number of elements in square brackets.
The document discusses arrays in Java, including how to declare and initialize one-dimensional and two-dimensional arrays, access array elements, pass arrays as parameters, and sort and search arrays. It also covers arrays of objects and examples of using arrays to store student data and daily temperature readings from multiple cities over multiple days.
The document discusses arrays in Java. It begins by defining what an array is - a structured data type that stores a fixed number of elements of the same type. It then covers how to declare and initialize one-dimensional arrays, manipulate array elements using loops and indexes, and how to pass arrays as parameters to methods. The document also discusses arrays of objects and multidimensional arrays.
This document provides an introduction to arrays in Java programming. It defines what arrays are, how they can store multiple values of the same type, and how they use indexes to access elements. The objectives are to develop programs that create and manipulate arrays. Key concepts covered include declaring and initializing arrays, assigning values, accessing elements, and using arrays in examples like storing image pixels or game grids. Code snippets demonstrate creating arrays of different types, assigning values, and a for loop to print array elements.
The document defines and describes different types of arrays in C programming. It states that arrays can hold multiple values of the same data type and are used to store data in linear or tabular form. The key types discussed are one-dimensional, two-dimensional, and multi-dimensional arrays. It provides examples and explains how to declare, initialize, search and sort each array type.
- Arrays allow storing multiple values in a single variable. They are useful for problems that require working with several variables at once, like calculating exam averages for 100 students.
- Arrays are initialized with a size and values can be stored and retrieved using indexes. Common issues include accessing indexes outside the array bounds or failing to initialize arrays properly.
- Command line arguments provide a way to pass user input to a program via the command line when it is launched. The arguments are stored in a String array that is initialized for the program.
Arrays can be passed to functions by reference, so any changes made to the array elements inside the function are reflected back in the calling function; the array name itself represents the base address of the array, which is passed to the function, while the size must be passed explicitly as a parameter; this allows the function to loop through the array and perform operations on each element using the indexes.
An array is a collection of variables of the same type referenced by a common name. A structure groups variables of different types. An array of structures combines these concepts by creating an array where each element is a structure. For example, an array of fraction structures could be defined to hold multiple fractions. Each structure element in the array contains a numerator and denominator integer. The entire array of structures occupies a contiguous block of memory with each structure taking up the same amount of space. Individual structure elements can then be accessed using the array index and dot notation.
The presentation introduces arrays, including their definition, types (one-dimensional, two-dimensional, multi-dimensional), syntax, declaration, accessing elements, and code examples. Arrays allow storing large amounts of data under a single variable name, facilitate faster searching, and are useful for representing matrices. They are a collection of similar data types indexed with integers.
Arrays are a collection of similar type of data that is fixed in size. The main advantage of arrays is that one variable can store multiple values, code is optimized by not needing multiple variables of the same type, and random access allows retrieval of any data by index value. The main limitation is that the size of an array cannot be increased or decreased once declared. There are single dimensional and multidimensional arrays, and arrays are created using the new keyword by specifying the size. Elements are accessed using their index value within brackets.
An array can hold all your variable values under a single name. And you can access the values by referring to the array name.
Each element in the array has its own index so that it can be easily accessed.
In PHP, there are three kind of arrays:
Numeric array - An array with a numeric index
Associative array - An array where each ID key is associated with a value
Multidimensional array - An array containing one or more arrays
This document discusses the different types of arrays in PHP. There are three main types: numeric arrays which use numeric indices, associative arrays where each key is associated with a value, and multi-dimensional arrays which contain one or more nested arrays. Examples are provided for each type to demonstrate how to define and access array elements.
This document provides an overview of stacks and queues as data structures. It discusses stacks and their LIFO (last-in, first-out) nature, as well as queues and their FIFO (first-in, first-out) nature. It covers the basic operations of each like push, pop, peek for stacks and enqueue, dequeue for queues. It provides examples of how to implement stacks and queues in code as well as examples of their uses.
This document discusses different types of collections that can be used to store data. It describes linear collections like arrays, lists, stacks and queues. It also describes nonlinear collections like trees, graphs and sets. For linear collections, it distinguishes between direct access collections like arrays which allow direct access by index, and sequential access collections like lists which require traversing the list. It provides examples of different collection classes and methods in C#.
This document discusses working with arrays in PHP. It covers array basics like creating and accessing arrays, looping through arrays with foreach and for loops, modifying arrays by adding/removing elements and sorting arrays. It also discusses multidimensional arrays, how to create them and access elements within them.
TKP Java Notes for Teaching Kids ProgrammingLynn Langit
Java programming concepts covered in the document include:
- Declaring and assigning variables such as strings and integers
- Incrementing and decrementing variable values using shortcuts like += and ++
- Using for and foreach loops to repeat actions
- Defining getter and setter methods to access and change variable values
- Creating and calling methods to organize code into reusable blocks
- Using conditionals like if/else statements to check conditions
- Storing and accessing values in data structures like arrays, arraylists, and hashmaps
- Implementing event listeners to handle user interactions like mouse clicks
- Defining a main method that kicks off the program execution
This document discusses object-oriented programming concepts like classes, objects, encapsulation, inheritance, polymorphism. It provides examples using a BankAccount class to demonstrate these concepts. A class defines attributes and behaviors for objects. Objects are instances of a class. Encapsulation hides implementation details and inheritance allows derived classes to extend existing classes. Polymorphism allows objects to take on different forms through inheritance. The instanceof operator is used to check an object's specific type.
Arrays are a data structure that allow the storage of multiple elements of the same type. They can have one or more dimensions. One-dimensional arrays use a single subscript, while two-dimensional arrays use two subscripts to reference rows and columns. Arrays can be passed as arguments to functions in several ways, including as a pointer, sized array, or unsized array. Arrays are useful for storing and sorting data, performing matrix operations, and storing temporary values in recursive functions. However, arrays have limitations such as a static size, requiring elements to be of the same type, and potential memory issues if not sized correctly.
This document discusses arrays in Java. It begins with an introduction to arrays as fixed-length data structures that hold multiple elements of the same type. The document then covers declaring and creating arrays, initializing arrays, and examples of using arrays, including summing array elements, displaying arrays in histograms, and analyzing survey results by storing responses in an array. The document also discusses passing arrays to methods by reference, meaning any changes made to the array in the method also change the original array. It provides an example program that passes an array to a method that directly modifies the array elements, as well as passing an array element by value so the method only modifies a copy of the primitive value.
Arrays allow for the storage of multiple values of the same data type in contiguous memory locations that can be accessed via indexes. In Java, arrays are objects that hold a collection of similar type elements. Arrays are declared with a type followed by empty brackets, and initialized using the new keyword along with the size of the array. Multidimensional arrays are arrays of arrays, allowing the use of multiple subscript operators to access elements.
An array is a sequential collection of data storage locations of the same type. Each storage location is called an element of the array. Arrays are collections of variables of the same type that are referred to through a common name, with each variable possessing a unique number called a subscript. Individual members of an array are called elements of the array. An array is declared by specifying the type followed by the array name and the number of elements in square brackets.
The document discusses arrays in Java, including how to declare and initialize one-dimensional and two-dimensional arrays, access array elements, pass arrays as parameters, and sort and search arrays. It also covers arrays of objects and examples of using arrays to store student data and daily temperature readings from multiple cities over multiple days.
The document discusses arrays in Java. It begins by defining what an array is - a structured data type that stores a fixed number of elements of the same type. It then covers how to declare and initialize one-dimensional arrays, manipulate array elements using loops and indexes, and how to pass arrays as parameters to methods. The document also discusses arrays of objects and multidimensional arrays.
This document provides an introduction to arrays in Java programming. It defines what arrays are, how they can store multiple values of the same type, and how they use indexes to access elements. The objectives are to develop programs that create and manipulate arrays. Key concepts covered include declaring and initializing arrays, assigning values, accessing elements, and using arrays in examples like storing image pixels or game grids. Code snippets demonstrate creating arrays of different types, assigning values, and a for loop to print array elements.
The document defines and describes different types of arrays in C programming. It states that arrays can hold multiple values of the same data type and are used to store data in linear or tabular form. The key types discussed are one-dimensional, two-dimensional, and multi-dimensional arrays. It provides examples and explains how to declare, initialize, search and sort each array type.
- Arrays allow storing multiple values in a single variable. They are useful for problems that require working with several variables at once, like calculating exam averages for 100 students.
- Arrays are initialized with a size and values can be stored and retrieved using indexes. Common issues include accessing indexes outside the array bounds or failing to initialize arrays properly.
- Command line arguments provide a way to pass user input to a program via the command line when it is launched. The arguments are stored in a String array that is initialized for the program.
Arrays can be passed to functions by reference, so any changes made to the array elements inside the function are reflected back in the calling function; the array name itself represents the base address of the array, which is passed to the function, while the size must be passed explicitly as a parameter; this allows the function to loop through the array and perform operations on each element using the indexes.
An array is a collection of variables of the same type referenced by a common name. A structure groups variables of different types. An array of structures combines these concepts by creating an array where each element is a structure. For example, an array of fraction structures could be defined to hold multiple fractions. Each structure element in the array contains a numerator and denominator integer. The entire array of structures occupies a contiguous block of memory with each structure taking up the same amount of space. Individual structure elements can then be accessed using the array index and dot notation.
The presentation introduces arrays, including their definition, types (one-dimensional, two-dimensional, multi-dimensional), syntax, declaration, accessing elements, and code examples. Arrays allow storing large amounts of data under a single variable name, facilitate faster searching, and are useful for representing matrices. They are a collection of similar data types indexed with integers.
Arrays are a collection of similar type of data that is fixed in size. The main advantage of arrays is that one variable can store multiple values, code is optimized by not needing multiple variables of the same type, and random access allows retrieval of any data by index value. The main limitation is that the size of an array cannot be increased or decreased once declared. There are single dimensional and multidimensional arrays, and arrays are created using the new keyword by specifying the size. Elements are accessed using their index value within brackets.
An array can hold all your variable values under a single name. And you can access the values by referring to the array name.
Each element in the array has its own index so that it can be easily accessed.
In PHP, there are three kind of arrays:
Numeric array - An array with a numeric index
Associative array - An array where each ID key is associated with a value
Multidimensional array - An array containing one or more arrays
This document discusses the different types of arrays in PHP. There are three main types: numeric arrays which use numeric indices, associative arrays where each key is associated with a value, and multi-dimensional arrays which contain one or more nested arrays. Examples are provided for each type to demonstrate how to define and access array elements.
This document provides an overview of stacks and queues as data structures. It discusses stacks and their LIFO (last-in, first-out) nature, as well as queues and their FIFO (first-in, first-out) nature. It covers the basic operations of each like push, pop, peek for stacks and enqueue, dequeue for queues. It provides examples of how to implement stacks and queues in code as well as examples of their uses.
This document discusses different types of collections that can be used to store data. It describes linear collections like arrays, lists, stacks and queues. It also describes nonlinear collections like trees, graphs and sets. For linear collections, it distinguishes between direct access collections like arrays which allow direct access by index, and sequential access collections like lists which require traversing the list. It provides examples of different collection classes and methods in C#.
This document discusses working with arrays in PHP. It covers array basics like creating and accessing arrays, looping through arrays with foreach and for loops, modifying arrays by adding/removing elements and sorting arrays. It also discusses multidimensional arrays, how to create them and access elements within them.
TKP Java Notes for Teaching Kids ProgrammingLynn Langit
Java programming concepts covered in the document include:
- Declaring and assigning variables such as strings and integers
- Incrementing and decrementing variable values using shortcuts like += and ++
- Using for and foreach loops to repeat actions
- Defining getter and setter methods to access and change variable values
- Creating and calling methods to organize code into reusable blocks
- Using conditionals like if/else statements to check conditions
- Storing and accessing values in data structures like arrays, arraylists, and hashmaps
- Implementing event listeners to handle user interactions like mouse clicks
- Defining a main method that kicks off the program execution
This document discusses object-oriented programming concepts like classes, objects, encapsulation, inheritance, polymorphism. It provides examples using a BankAccount class to demonstrate these concepts. A class defines attributes and behaviors for objects. Objects are instances of a class. Encapsulation hides implementation details and inheritance allows derived classes to extend existing classes. Polymorphism allows objects to take on different forms through inheritance. The instanceof operator is used to check an object's specific type.
PHP Basic and Fundamental Questions and Answers with Detail ExplanationOXUS 20
The document contains a 14 page questionnaire about PHP basics and fundamentals. It includes multiple choice and explanation questions about PHP syntax, variables, data types, operators, functions, arrays and more.
The first part contains 25 multiple choice questions testing knowledge of PHP basics like tags, syntax, variables, operators, functions, conditional and loop statements. The second part has 7 additional multiple choice questions focusing on built-in functions, arrays, filters and regular expressions. The third part asks to explain two tricky PHP code examples.
In summary, the document is a comprehensive skills assessment covering PHP fundamentals through multiple choice and explanation questions. It tests a wide range of PHP concepts and features to evaluate proficiency with the language.
This presentation introduces Java Applet and Java Graphics in detail with examples and finally using the concept of both applet and graphics code the analog clock project to depict how to use them in real life challenges and applications.
The document discusses conditional statements in Java programming. It covers if statements, if-else statements, logical operators, and nested if statements. It explains how conditional statements allow programmers to make decisions in code based on boolean expressions evaluating to true or false. Examples are provided to demonstrate if statements, if-else statements, logical operators like && and ||, and the use of block statements with conditional logic.
Fal-e-Hafez (Omens of Hafez) Cards in Persian using JavaOXUS 20
This document describes an application called "Omens of Hafez Cards in Persian Using JAVA" that generates random quotes from the poems of Hafez. It discusses the concepts of File I/O, random number generation, and component orientation used to build the application interface. Code examples are provided to demonstrate reading and writing files, generating random numbers, reading input from the keyboard and files using Scanner, and setting component orientation. The application is implemented using classes like File, Random, Scanner and adjusts orientation using ComponentOrientation.
The document discusses various validation techniques using regular expressions in Java, including username validation, password validation, password strength checking, email validation, and image file extension validation. Regular expressions are used to validate inputs match common patterns for things like usernames containing 3-15 characters, passwords being a minimum length and containing uppercase, lowercase, numbers and symbols, email addresses having the correct format, and image file extensions being formats like jpg, png, etc. Code examples and demonstrations are provided for each validation technique.
With Unicode you can program and accomplish many funny, cool and useful programs and tools as for instance, Abjad Calculator calculating the numerical value of letters derived from the Arabic alphabet through the use of the Abjad writing system, Bubble Text Generator to write letters in circle, Flip Text Generator to write letters upside down, Google Transliteration to convert English names to Persian/Arabic, etc.
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesOXUS 20
A Virtual Keyboard is considered to be a component to use on computers without a real keyboard e.g. Touch Screen Computers and Smart Phones; where a mouse can utilize the keyboard functionalities and features.
In addition, Virtual Keyboard used for the following subjects: Foreign Character Sets, Touchscreen, Bypass Key Loggers, etc.
To review computer basics, programs, and operating systems
To explore the relationship between Java and the World Wide Web
To distinguish the terms API, IDE, and JDK
To write a simple Java program
To display output on the console
To explain the basic syntax of a Java program
To create, compile, and run Java programs
(GUI) To display output using the JOptionPane output dialog boxes
Object Oriented Concept Static vs. Non StaticOXUS 20
Static is not the true intend of Object Oriented Design and Concept.
For instance, we turn a LAMP "off" it does not suppose to turn the LAMPS of the entire world goes "off".
This tutorial explains step by step writing a simple guessing game where the player guess the number selected by the computer and the goal is to introduce the power and usage of RANDOM as well as the how to benefit CURRENTTIMEMILLIS method of the System class in order to check how much it took the player guessing the correct number.
Web Design and Development Life Cycle and TechnologiesOXUS 20
This presentation is an introduction to the design, creation, and maintenance of web design and development life cycle and web technologies. With it, you will learn about the web technologies, the life cycle of developing an efficient website and web application and finally some web essentials questions will be provided and reviewed.
Create Splash Screen with Java Step by StepOXUS 20
This presentation guide you how to make a custom Splash Screen step by step using Java Programming. In addition, you will learn the concept and usage of Java Timer, Java Progress Bar and Window ...
Everything about Database JOINS and RelationshipsOXUS 20
Today, we continue our journey into the world of RDBMS (relational database management systems) and SQL (Structured Query Language).
In this presentation, you will understand about some key definitions and then you will learn how to work with multiple tables that have relationships with each other.
First, we will go covering some core concepts and key definitions, and then will begin working with JOINs queries in SQL.
This document discusses how to set up remote debugging of a Java application from Eclipse. It explains that the debugee (Java application) needs to be run with JDWP options to enable debugging, including suspending the application at startup. The debugger (Eclipse) then connects to the debug port to inspect and control the debugee. An example Java application is provided that toggles a button color when clicked, which can be remotely debugged from Eclipse.
The document discusses the final keyword in Java and provides examples of using final with variables, methods, and classes. It then summarizes abstract classes and interfaces in Java, including how to declare abstract classes and methods and how interfaces are used to achieve abstraction and multiple inheritance. The document also covers packages, access modifiers, encapsulation, and arrays in Java.
With Unicode you can program and accomplish many funny, cool and useful programs and tools as for instance, Abjad Calculator, Bubble Text Generator to write letters in circle, Flip Text Generator to write letters upside down, Google Transliteration to convert English names to Persian/Arabic, etc...
Java Virtual Keyboard Using Robot, Toolkit and JToggleButton ClassesAbdul Rahman Sherzad
A Virtual Keyboard is considered to be a component to use on computers without a real keyboard e.g. Touch Screen Computers and Smart Phones; where a mouse can utilize the keyboard functionalities and features.
In addition, Virtual Keyboard used for the following subjects: Foreign Character Sets, Touchscreen, Bypass Key Loggers, etc.
Jdbc Complete Notes by Java Training Center (Som Sir)Som Prakash Rai
This Jdbc (Java Database Connectivity) notes contains the complete indepth Explanation of JDBC by Som Prakash Rai Sir. This is the Running notes of java Training center ,(J.T.C Noida), www.jtcindia.org
This document provides an introduction to basic Java programming concepts such as programs, programming languages, compiling and running Java programs, and Java syntax. It explains that a Java program consists of a class containing a main method with print statements. Various Java concepts are defined, such as identifiers, keywords, strings, escape sequences, and syntax errors. Examples of Java print statements and their output are provided.
This document provides examples of Java programming concepts and code snippets to demonstrate how to implement various Java features. It includes examples for Java basics like strings, arrays, files and directories as well as more advanced topics like collections, networking, threading and GUI programming. Each section breaks down a specific concept like string manipulation or environment settings into discrete code examples that show how to perform common tasks like comparing strings, setting the classpath, or splitting a string.
This document provides an overview and tutorial on querying DBpedia using the Jena framework. It introduces Jena and its capabilities for working with RDF data, describes how to set up a development environment in Netbeans or Eclipse, and provides examples of querying DBpedia's SPARQL endpoint to retrieve information about people and locations. Other APIs for working with RDF in languages like PHP, Python, and C are also briefly mentioned.
The document discusses modern Java constructs introduced after Java 5, including collections, generics, autoboxing, enumerated types, annotations, and how to properly design classes to work with collections. It provides code examples and best practices for using these constructs and highlights resources like Java in a Nutshell and Effective Java for further reading.
This knowledge capsule highlights the importance of well-known software design principle: "Design To Interface", also known as "Interfacebased Programming". All the best. :-)
This document discusses regular expressions and their use in QuickTest. Regular expressions allow QuickTest to match text and object properties that may vary between test runs. They can be used to define object properties, parameterize steps, and create checkpoints for varying values. Key points covered include regular expression syntax like wildcards, character sets, and quantifiers; and how to set the RegularExpression property to treat a property value as a regular expression rather than a literal string.
Java is a mature programming language that is suitable to write reliable large programs. But Java hides also many traps. This talk summarizes experience from code quality review of a large enterprise application with over 1.5 million lines of code - problems and hidden bugs in code, and how to solve them.
Slides of my presentations at PyData NYC. This PDF is extracted from a Jupyter RISE slideset available at http://nbviewer.ipython.org/format/slides/github/lechatpito/PyDataNYC2015/blob/master/Word%20embeddings%20as%20a%20service%20-%20PyData%20NYC%202015%20%20.ipynb#/
This document provides a summary of key Java concepts and answers to common Java interview questions. It begins with an introduction explaining what the presentation covers. The bulk of the document consists of questions and detailed answers on topics like exceptions, abstract classes, strings, arrays, collections, inheritance and polymorphism.
The Template class provides a way to format data using templates with embedded symbols. Templates consist of a string with #{fieldName} placeholders that are replaced with values from an object when evaluate() is called. Templates can be reused with different data objects and support escape sequences and custom placeholder syntax. evaluate() applies the template to an object, returning a formatted string.
Everyone wants to jump into HTML5 but how do you use the cool features of this new specification while ensuring existing and future browsers render your web pages as expected? This is where feature detection, Modernizr, polyfills and shims come in. In the session, you’ll learn the best practices and strategy to code with HTML5 and CSS3 features that won’t break for the existing and future browsers. You’ll learn step by step how to use specially crafted JavaScript and CSS code that emulate HTML5 features. Also, a real-life case study will be used to demonstrate step by step how to build Cross-Browser Plug-in-Free experiences. With a couple of simple changes to your sites, you can take advantage of HTML5 today without breaking your sites in the future. Expect a lot of demos and code in the session.
Its very happy to introduced ourself. Our
Institution Adroit Infogen Pvt. Ltd. Corporation is
the industry leader in reliability consulting and
training services
Has been founded in 2007 by Mr.R.Praneeth
Reddy .
It is to inform that we have been chosen as one
of the outsourcing agencies to start IT related
ESDP's [Entrepreneurship & Skill Development
Programs] by NI-MSME. In this connection we
wish to inform that we are conducting free
training programs for the students which
provided the certification in different programs
by NI-MSME, Ministry of MSME, Govt of India)
This document discusses client-side form validation using JavaScript. It begins by introducing client-side validation and how it provides validation in the browser through JavaScript downloaded with the web page, making it generally faster than server-side validation. It then covers techniques for client-side validation including checking for empty fields, using regular expressions to validate formats, and JavaScript methods like test(), exec(), replace(), match(), and search() that can be used to validate form fields.
Slides from talk given at Ithaca Web Group and GORGES on CoffeeScript.
The focus is on explaining to people who haven't tried it yet that it's more than syntactic sugar. There are several real life code examples but they were explained verbally so they may not be super helpful if you don't know CoffeeScript yet.
It's an overview, not a tutorial.
JAVA Tutorial- Do's and Don'ts of Java programmingKeshav Kumar
Whether you program regularly in Java, and know it like the back of your hand, or whether you’re new to the language or a casual programmer, you’ll make mistakes. The purpose of this webinar is to talk about some Do's and Don'ts of Java programming.
The webinar will cover the following areas:
- Top 10 mistakes made by Java programmers – How to avoid them
- Core Java- Best Practices – This covers good and bad practices both
- How to prepare for Java Interviews and Sun Java Exams
- Q&A
Key learnings from this webinar:
- It will benefit both junior and senior java professionals so that they don’t make common errors
- Clarity of concepts of Java
- Better awareness of best practices of Java
JAVA Tutorial- Do's and Don'ts of Java programmingKeshav Kumar
Whether you program regularly in Java, and know it like the back of your hand, or whether you’re new to the language or a casual programmer, you’ll make mistakes. The purpose of this webinar is to talk about some Do's and Don'ts of Java programming.
The webinar will cover the following areas:
- Top 10 mistakes made by Java programmers – How to avoid them
- Core Java- Best Practices – This covers good and bad practices both
- How to prepare for Java Interviews and Sun Java Exams
- Q&A
Key learnings from this webinar:
- It will benefit both junior and senior java professionals so that they don’t make common errors
- Clarity of concepts of Java
- Better awareness of best practices of Java
This document discusses PHP functions and arrays. It defines PHP functions as reusable blocks of code that can be called repeatedly using the function name. User-defined functions in PHP start with the "function" keyword. Functions can accept arguments and return values. Arrays allow storing multiple values in a single variable and accessing them via numeric indexes. The document provides examples of creating, accessing, and looping through indexed arrays in PHP code.
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
This document provides an overview of type conversion and regular expressions in JavaScript. It discusses how JavaScript variables can be converted between different data types either automatically or using functions. It covers converting between numbers, strings, booleans, and dates. It also provides an introduction to regular expressions including patterns, modifiers, and examples of using regular expression methods like exec(), test(), search(), split(), and replace() on strings. The document includes exercises for readers to practice these concepts.
The document discusses Java methods, including creating and calling methods, passing parameters, overloading methods, and method abstraction. It provides examples of void and non-void methods. Key points covered include defining method headers and bodies, passing arguments by value, variable scope, and using built-in Math class methods like random, min, max, and trigonometric functions.
Fundamentals of Database Systems Questions and AnswersOXUS 20
Fundamentals of Database Systems questions and answers with explanation for fresher's and experienced for interview, competitive examination and entrance test.
The document discusses GUI event handling in Java. It explains that window-based Java programs are event-driven, meaning they wait for and respond to user-initiated events like button clicks or key presses. When an event occurs, an event object is passed to a listener object that handles the event. Listeners implement interfaces that correspond to different event types, like ActionListener for button clicks. The delegation event model in Java handles event passing from components to listeners.
Java GUI PART II is the continues of JAVA GUI PART I covering and discussing the GUI components as well as the different available Layout Managers which is available in JAVA and you can find dedicated example for each Layout Managers …
A Graphical User Interface (GUI) is a user interface based on graphics i.e. icons, pictures, menus, etc. instead of just plain text, it uses a mouse as well as a keyboard as an input device.
GUI applications enable the users (especially naive ones) to interact with a system easily and friendly. This presentation is meant for the individual who has little or no experience in Java GUI programming.
JAVA Programming Questions and Answers PART IIIOXUS 20
Oxus20 is a non-profit organization aimed at improving education by providing training and assistance to IT and computer science professionals. The name Oxus20 comes from the Amu Darya river, the largest river in Central Asia, which represents the hidden talents that the organization aims to develop. The organization seeks to create an environment conducive to nurturing talent and creativity among students and researchers, institutionalize extra-curricular scientific activities, identify gifted individuals to involve in advancing the scientific community, and produce specialized publications to disseminate modern science and technology in society.
Communicating effectively and consistently with students can help them feel at ease during their learning experience and provide the instructor with a communication trail to track the course's progress. This workshop will take you through constructing an engaging course container to facilitate effective communication.
Leveraging Generative AI to Drive Nonprofit InnovationTechSoup
In this webinar, participants learned how to utilize Generative AI to streamline operations and elevate member engagement. Amazon Web Service experts provided a customer specific use cases and dived into low/no-code tools that are quick and easy to deploy through Amazon Web Service (AWS.)
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
Chapter wise All Notes of First year Basic Civil Engineering.pptxDenish Jangid
Chapter wise All Notes of First year Basic Civil Engineering
Syllabus
Chapter-1
Introduction to objective, scope and outcome the subject
Chapter 2
Introduction: Scope and Specialization of Civil Engineering, Role of civil Engineer in Society, Impact of infrastructural development on economy of country.
Chapter 3
Surveying: Object Principles & Types of Surveying; Site Plans, Plans & Maps; Scales & Unit of different Measurements.
Linear Measurements: Instruments used. Linear Measurement by Tape, Ranging out Survey Lines and overcoming Obstructions; Measurements on sloping ground; Tape corrections, conventional symbols. Angular Measurements: Instruments used; Introduction to Compass Surveying, Bearings and Longitude & Latitude of a Line, Introduction to total station.
Levelling: Instrument used Object of levelling, Methods of levelling in brief, and Contour maps.
Chapter 4
Buildings: Selection of site for Buildings, Layout of Building Plan, Types of buildings, Plinth area, carpet area, floor space index, Introduction to building byelaws, concept of sun light & ventilation. Components of Buildings & their functions, Basic concept of R.C.C., Introduction to types of foundation
Chapter 5
Transportation: Introduction to Transportation Engineering; Traffic and Road Safety: Types and Characteristics of Various Modes of Transportation; Various Road Traffic Signs, Causes of Accidents and Road Safety Measures.
Chapter 6
Environmental Engineering: Environmental Pollution, Environmental Acts and Regulations, Functional Concepts of Ecology, Basics of Species, Biodiversity, Ecosystem, Hydrological Cycle; Chemical Cycles: Carbon, Nitrogen & Phosphorus; Energy Flow in Ecosystems.
Water Pollution: Water Quality standards, Introduction to Treatment & Disposal of Waste Water. Reuse and Saving of Water, Rain Water Harvesting. Solid Waste Management: Classification of Solid Waste, Collection, Transportation and Disposal of Solid. Recycling of Solid Waste: Energy Recovery, Sanitary Landfill, On-Site Sanitation. Air & Noise Pollution: Primary and Secondary air pollutants, Harmful effects of Air Pollution, Control of Air Pollution. . Noise Pollution Harmful Effects of noise pollution, control of noise pollution, Global warming & Climate Change, Ozone depletion, Greenhouse effect
Text Books:
1. Palancharmy, Basic Civil Engineering, McGraw Hill publishers.
2. Satheesh Gopi, Basic Civil Engineering, Pearson Publishers.
3. Ketki Rangwala Dalal, Essentials of Civil Engineering, Charotar Publishing House.
4. BCP, Surveying volume 1
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
Temple of Asclepius in Thrace. Excavation resultsKrassimira Luka
The temple and the sanctuary around were dedicated to Asklepios Zmidrenus. This name has been known since 1875 when an inscription dedicated to him was discovered in Rome. The inscription is dated in 227 AD and was left by soldiers originating from the city of Philippopolis (modern Plovdiv).
This document provides an overview of wound healing, its functions, stages, mechanisms, factors affecting it, and complications.
A wound is a break in the integrity of the skin or tissues, which may be associated with disruption of the structure and function.
Healing is the body’s response to injury in an attempt to restore normal structure and functions.
Healing can occur in two ways: Regeneration and Repair
There are 4 phases of wound healing: hemostasis, inflammation, proliferation, and remodeling. This document also describes the mechanism of wound healing. Factors that affect healing include infection, uncontrolled diabetes, poor nutrition, age, anemia, the presence of foreign bodies, etc.
Complications of wound healing like infection, hyperpigmentation of scar, contractures, and keloid formation.
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
1. » String Manipulation
» Matching / Validating
» Extracting / Capturing
» Modifying / Substitution
https://www.facebook.com/Oxus20
oxus20@gmail.com
Java
Regular
Expression
PART I
Abdul Rahman Sherzad
2. Agenda
» What is Regular Expression
» Regular Expression Syntax
˃ Character Classes
˃ Quantifiers
˃ Meta Characters.
» Basic Expression Example
» Basic Grouping Example
» Matching / Validating
» Extracting/Capturing
» Modifying/Substitution
https://www.facebook.com/Oxus20
2
3. What are Regular Expressions?
» Regular Expressions are a language of string patterns built
into most modern programming languages, Perl, PHP, .NET
and including Java 1.4 onward.
» A regular expression defines a search pattern for strings.
» Regular expressions can be used to search, edit and
manipulate text.
» The abbreviation for Regular Expression is Regex.
3
https://www.facebook.com/Oxus20
4. Regular Expression Syntax
» Regular Expressions, by definition, are string patterns
that describe text.
» These descriptions can then be used in nearly infinite
ways.
» The basic language constructs include
˃ Character Classes
˃ Quantifiers
˃ Meta Characters.
4
https://www.facebook.com/Oxus20
5. Character Classes
Character
Class
Explanation and Alternatives
.
Match any character (may or may not match line terminators)
d
Matches a digit, is an alternative for:
D
Matches a non-digit character, is an alternative for:
s
Matches a whitespace character, is an alternative for:
[0-9]
[^0-9]
[ tnx0Bfr]
S
Matches a non-whitespace character, is an alternative for:
w
Match a word character, is an alternative for:
W
Match a non-word character, is an alternative for:
[^s]
[a-zA-Z_0-9]
[^w]
NOTE: in Java, you will need to "double escape" these backslashes "" i.e. "d" should be "d".
5
https://www.facebook.com/Oxus20
6. Quantifiers
Quantifiers Explanation and Alternatives
*
Match zero or more times, is an alternative for
+
Match one or more times, is an alternative for
{1,}
?
Match no or one times, ? is an alternative for
{0,1}
{n}
Match exactly
{n,}
Match at least
n times,
{n,m}
Match at least
n but not more than m times
{0,}
n number of times
Quantifiers can be used to specify the number or length that part of a
pattern should match or repeat.
https://www.facebook.com/Oxus20
6
7. Meta Characters
Meta
Characters
Explanation
Escape the next meta-character (it becomes a normal
/ literal character)
Match the beginning of the line
^
.
Match any character (except newline)
$
Match the end of the line (or before newline at the
end)
Alternation for ('or' statement)
|
()
Grouping
[]
Custom character class
Meta-characters are used to group, divide, and perform special
operations in patterns.
https://www.facebook.com/Oxus20
7
8. Basic Expression: Example I
» Every string is a Regular Expression.
» For example, the string, "I study English", is a regular
expression that will match exactly the string, "I study
English", and will ignore everything else.
» What if we want to be able to find more subject that
we study? We can replace the word English with a
character class expression that will match any
subject. Example on next slide …
8
https://www.facebook.com/Oxus20
9. Basic Expression: Example II
"I study w+"
» As you can see, the above pattern "I study w+" uses
both a character class and a quantifier.
» The character class "w" says match a word character
» The quantifier "+" says match one or more.
» Now the pattern "I study w+" will match any word in
place of "English" i.e. "I study Programming", "I study
Math", "I study Database", etc.
https://www.facebook.com/Oxus20
9
10. Example II Demo
public class RegexBasicExampleII {
public static void main(String[] args) {
System.out.println("I study English".matches("I study w+")); // true
System.out.println("I study Programming".matches("I study w+")); // true
System.out.println("I study JAVA".matches("I study w+")); // true
System.out.println("I study: JAVA".matches("I study w+")); // false
}
}
10
https://www.facebook.com/Oxus20
11. Example II Demo (Alternative)
public class RegexBasicExampleII {
public static void main(String[] args) {
System.out.println("I study English".matches("I study [a-zA-Z_0-9]+")); // true
System.out.println("I study Programming".matches("I study [a-zA-Z_0-9]+")); // true
System.out.println("I study JAVA".matches("I study [a-zA-Z_0-9]+")); // true
System.out.println("I study: JAVA".matches("I study [a-zA-Z_0-9]+")); // false
}
}
11
https://www.facebook.com/Oxus20
12. Basic Expression: Example III
» But the pattern "I study w+" will not match "I study:
English", because as soon as the expression finds the ":"
character, which is not a word character, it will stop
matching.
» If we want the expression to be able to handle this
situation, then we need to make a small change as follow:
» "I study:? w+"
» Now the pattern "I study:? w+" will match "I study
Programming" and also "I study: Programming"
12
https://www.facebook.com/Oxus20
13. Example III Demo
public class RegexBasicExampleIII {
public static void main(String[] args) {
System.out.println("I study English".matches("I study:? w+")); // true
System.out.println("I study Programming".matches("I study:? w+")); // true
System.out.println("I study JAVA".matches("I study:? w+")); // true
System.out.println("I study: JAVA".matches("I study:? w+")); // true
}
}
13
https://www.facebook.com/Oxus20
14. Basic Expression: Example IV
» Also the pattern "I study w+" will not match neither the
string "i study English" and nor "I Study English" , because as
soon as the expression finds the lowercase "i", which is not
equal uppercase "I", it will stop matching.
» If we want the expression to be able to handle this situation
does not care about the case sensitivity then we need to make a
small change as follow:
» "(?i)I study w+"
» Now the pattern "(?i)I study w+" will match both "I STUDY
JAVA" and also "i StUdY JAVA"
https://www.facebook.com/Oxus20
14
15. Example IV Demo
public class RegexBasicExampleIV {
public static void main(String[] args) {
System.out.println("I study English".matches("(?i)I study w+")); // true
System.out.println("i STUDY English".matches("(?i)I study w+")); // true
System.out.println("I study JAVA".matches("(?i)I study w+")); // true
System.out.println("i StUdY JAVA".matches("(?i)I study w+")); // true
}
}
15
https://www.facebook.com/Oxus20
16. Regular Expression Basic Grouping
» An important feature of Regular Expressions is the
ability to group sections of a pattern, and provide
alternate matches.
» The following two meta-characters are core parts of
flexible Regular Expressions
˃ | Alternation ('or' statement)
˃ () Grouping
» Consider if we know exactly subjects we are studying, and we
want to find only those subjects but nothing else. Following is
the pattern:
» "I study (Java|English|Programming|Math|Islamic|HTML)"
16
https://www.facebook.com/Oxus20
17. Regular Expression Basic Grouping
» "I study (Java|English|Programming|Math|Islamic|HTML)"
» The new expression will now match the beginning of the string "I
study", and then any one of the subjects in the group, separated by
alternators, "|"; any one of the following would be a match:
˃ Java
˃ English
˃ Programming
˃ Math
˃ Islamic
˃ HTML
17
https://www.facebook.com/Oxus20
18. Basic Grouping Demo I (Case Sensitive)
public class BasicGroupingDemoI {
public static void main(String[] args) {
String pattern = "I study (Java|English|Programming|Math|Islamic|HTML)";
System.out.println("I study English".matches(pattern)); // true
System.out.println("I study Programming".matches(pattern)); // true
System.out.println("I study Islamic".matches(pattern)); // true
// english with lowercase letter "e" is not in our group
System.out.println("I study english".matches(pattern)); // false
// CSS is not in our group
System.out.println("I study CSS".matches(pattern)); // false
}
}
18
https://www.facebook.com/Oxus20
19. Basic Grouping Demo I (Case Insensitive)
public class BasicGroupingDemoI {
public static void main(String[] args) {
String pattern = "(?i)I study (Java|English|Programming|Math|Islamic|HTML)";
System.out.println("I study English".matches(pattern)); // true
System.out.println("I study Programming".matches(pattern)); // true
System.out.println("I study Islamic".matches(pattern)); // true
System.out.println("I study english".matches(pattern)); // true
// CSS is not in our group
System.out.println("I study CSS".matches(pattern)); // false
}
}
19
https://www.facebook.com/Oxus20
20. Matching / Validating
» Regular Expressions make it possible to find all instances of
text that match a certain pattern, and return a Boolean
value if the pattern is found / not found.
» This can be used to validate user input such as
˃
˃
˃
˃
˃
Phone Numbers
Social Security Numbers (SSN)
Email Addresses
Web Form Input Data
and much more.
» Consider the purpose is to validate the SSN if the pattern is
found in a String, and the pattern matches a SSN, then the
string is an SSN.
20
https://www.facebook.com/Oxus20
21. SSN Match and Validation
public class SSNMatchAndValidate {
public static void main(String[] args) {
String pattern = "^(d{3}-?d{2}-?d{4})$";
String input[] = new String[5];
input[0]
input[1]
input[2]
input[3]
input[4]
=
=
=
=
=
"123-45-6789";
"9876-5-4321";
"987-650-4321";
"987-65-4321 ";
"321-54-9876";
for (int i = 0; i < input.length; i++)
if (input[i].matches(pattern)) {
System.out.println("Found correct
}
}
OUTPUT:
}
Found correct
}
Found correct
https://www.facebook.com/Oxus20
{
SSN: " + input[i]);
SSN: 123-45-6789
SSN: 321-54-9876
21
22. SSN Match and Validation Detail
"^(d{3}-?d{2}-?d{4})$"
Regular
// 123-45-6789
Meaning
Expression
^
match the beginning of the line
()
group everything within the parenthesis as group 1
d{3}
match only 3 digits
-?
optionally match a dash
d{2}
match only 2 digits
-?
optionally match a dash
d{4}
match only 4 digits
$
match the end of the line
https://www.facebook.com/Oxus20
22
23. SSN Match and Validation (Alternative)
public class SSNMatchAndValidateII {
public static void main(String[] args) {
String pattern = "^([0-9]{3}-?[0-9]{2}-?[0-9]{4})$";
String input[] = new String[5];
input[0]
input[1]
input[2]
input[3]
input[4]
=
=
=
=
=
"123-45-6789";
"9876-5-4321";
"987-650-4321";
"987-65-4321 ";
"321-54-9876";
for (int i = 0; i < input.length; i++)
if (input[i].matches(pattern)) {
System.out.println("Found correct
}
}
OUTPUT:
}
Found correct
}
Found correct
https://www.facebook.com/Oxus20
{
SSN: " + input[i]);
SSN: 123-45-6789
SSN: 321-54-9876
23
24. SSN Match and Validation Detail
"^([0-9]{3}-?[0-9]{2}-?[0-9]{4})$"
Regular
// 123-45-6789
Meaning
Expression
^
match the beginning of the line
()
group everything within the parenthesis as group 1
[0-9]{3}
match only 3 digits
-?
optionally match a dash
[0-9]{2}
match only 2 digits
-?
optionally match a dash
[0-9]{4}
match only 4 digits
$
match the end of the line
https://www.facebook.com/Oxus20
24
25. Extracting / Capturing
» Capturing groups are an extremely useful feature of
Regular Expression matching that allow us to query
the Matcher to find out what the part of the string was that
matched against a particular part of the regular expression.
» Consider you have a large complex body of text (with an
unspecified number of numbers) and you would like to
extract all the numbers.
» Next Slide demonstrate the example
25
https://www.facebook.com/Oxus20
26. Extracting / Capturing Numbers
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ExtractingNumbers {
public static void main(String[] args) {
String text = "Abdul Rahman Sherzad with university ID of 20120 is trying to
demonstrate the power of Regular Expression for OXUS20 members.";
Pattern p = Pattern.compile("d+");
Matcher m = p.matcher(text);
while (m.find()) {
System.out.println(m.group());
}
OUTPUT:
20120
20
}
}
https://www.facebook.com/Oxus20
26
27. Extracting / Capturing Explanation
» Import the needed classes
import java.util.regex.Matcher;
import java.util.regex.Pattern;
» First, you must compile the pattern
Pattern p = Pattern.compile("d+");
» Next, create a matcher for a target text by sending a message to your
pattern
Matcher m = p.matcher(text);
» NOTES
˃ Neither Pattern nor Matcher has a public constructor;
+ use static Pattern.compile(String regExpr) for creating pattern
instances
+ using Pattern.matcher(String text) for creating instances of
matchers.
˃ The matcher contains information about both the pattern and the
target text.
https://www.facebook.com/Oxus20
27
28. Extracting / Capturing
Explanation
» m.find()
˃ returns true if the pattern matches any part of the
text string,
˃ If called again, m.find() will start searching from
where the last match was found
˃ m.find() will return true for as many matches as
there are in the string; after that, it will return false
28
https://www.facebook.com/Oxus20
29. Extract / Capture Emails
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ExtractEmails {
public static void main(String[] args) {
String text = "Abdul Rahman Sherzad absherzad@gmail.com
on OXUS20 oxus20@gmail.com";
String pattern = "[A-Za-z0-9-_]+(.[A-Za-z0-9-_]+)*@[AZa-z0-9-]+(.[A-Za-z0-9]+)*(.[A-Za-z]{2,})";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(text);
while (m.find()) {
System.out.println(m.group());
}
}
OUTPUT:
absherzad@gmail.com
oxus20@gmail.com
}
https://www.facebook.com/Oxus20
29
30. Modifying / Substitution
» Values in String can be replaced with new values
» For example, you could replace all instances of the
word 'StudentID=', followed by an ID, with a mask to
hide the original ID.
» This can be a useful method of filtering sensitive
information.
» Next Slide demonstrate the example
30
https://www.facebook.com/Oxus20
31. Mask Sensitive Information
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Substitutions {
public static void main(String[] args) {
String text = "Three student with StudentID=20120, StudentID=20121 and
finally StudentID=20122.";
Pattern p = Pattern.compile("(StudentID=)([0-9]+)");
Matcher m = p.matcher(text);
StringBuffer result = new StringBuffer();
while (m.find()) {
System.out.println("Masking: " + m.group(2));
m.appendReplacement(result, m.group(1) + "***masked***");
}
m.appendTail(result);
System.out.println(result);
}
31
}
https://www.facebook.com/Oxus20
32. Mask Sensitive Information
(OUTPUT)
» Masking: 20120
» Masking: 20121
» Masking: 20122
» Three student with StudentID=***masked***,
StudentID=***masked*** and finally
StudentID=***masked***.
32
https://www.facebook.com/Oxus20
33. Conclusion
» Regular Expressions are not easy to use at first
˃ It is a bunch of punctuation, not words
˃ It takes practice to learn to put them together correctly.
» Regular Expressions form a sub-language
˃ It has a different syntax than Java.
˃ It requires new thought patterns
˃ Can't use Regular Expressions directly in java; you have to create Patterns
and Matchers first or use the matches method of String class.
» Regular Expressions is powerful and convenient
to use for string manipulation
˃ It is worth learning!!!
33
https://www.facebook.com/Oxus20