String Manipulation.

Slides:



Advertisements
Similar presentations
 2002 Prentice Hall. All rights reserved. 1 Chapter 15 – Strings, Characters and Regular Expressions Outline 15.1Introduction 15.2 Fundamentals of Characters.
Advertisements

Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
Strings in Java 1. strings in java are handled by two classes String &
1 Working with String Duo Wei CS110A_ Empty Strings An empty string has no characters; its length is 0. Not to be confused with an uninitialized.
1 Strings and Text I/O. 2 Motivations Often you encounter the problems that involve string processing and file input and output. Suppose you need to write.
Java Programming Strings Chapter 7.
©2004 Brooks/Cole Chapter 7 Strings and Characters.
Chapter 8: Manipulating Strings
 2006 Pearson Education, Inc. All rights reserved Strings, Characters and Regular Expressions.
 Pearson Education, Inc. All rights reserved Strings, Characters and Regular Expressions.
Chapter 5 new The Do…Loop Statement
1.
Lesson 3 – Regular Expressions Sandeepa Harshanganie Kannangara MBCS | B.Sc. (special) in MIT.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Array String String Builder. Arrays Arrays are collections of several elements of the same type E.g. 100 integers, 20 strings, 125 students, 12 dates,
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
CSCI 3327 Visual Basic Chapter 12: Strings, Characters and Regular Expressions UTPA – Fall 2011.
C# Strings 1 CNS 3260 C#.NET Software Development.
ASP.NET Programming with C# and SQL Server First Edition Chapter 5 Manipulating Strings with C#
Lecture 14 March 23, Exam Results Class Average was 69.4 –Median was 72.5 (which means there were some very low grades) Questions 31, 32, and 33.
Chapter 8: Manipulating Strings
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
C# Strings 1 C# Regular Expressions CNS 3260 C#.NET Software Development.
Chapter 7: Characters, Strings, and the StringBuilder.
CSCI 3327 Visual Basic Chapter 12: Strings, Characters and Regular Expressions UTPA – Fall 2011.
String String Builder. System.String string is the alias for System.String A string is an object of class string in the System namespace representing.
17-Feb-16 String and StringBuilder Part I: String.
 2009 Pearson Education, Inc. All rights reserved. 1 Ch.18 Strings, Characters [and Regular Expressions] Many slides modified by Prof. L. Lilien (even.
Strings A string is a sequence of characters that is treated as a single value. Strings are objects. We have been using strings all along. For example,
String. 2 Objectives Discuss string handling –System.String class –System.Text.StringBuilder class.
Microsoft Visual Basic 2008: Reloaded Third Edition
Computer Programming ||
Strings, Characters and Regular Expressions
Strings, Characters and Regular Expressions
Strings, StringBuilder, and Character
Strings, Characters and Regular Expressions
Strings and Characters
String and String Buffers
String String Builder.
Primitive Types Vs. Reference Types, Strings, Enumerations
VB Math All of your favorite mathematical operators are available in VB: + Addition - Subtraction * Multiplication / Division \ Integer Division Mod Modulo.
String and StringBuilder
MSIS 655 Advanced Business Applications Programming
Chapter 5 The Do…Loop Statement
Advanced String handling
String and StringBuilder
CIS16 Application Development and Programming using Visual Basic.net
التعامل مع النصوص string T/Arwa Al-Sarami.
String class and its objects
String Manipulation and More Controls
Strings and Characters
Java – String Handling.
16 Strings.
Microsoft Visual Basic 2005: Reloaded Second Edition
Microsoft Visual Basic 2005: Reloaded Second Edition
String and StringBuilder
CS2011 Introduction to Programming I Strings
Topics Basic String Operations String Slicing
String methods 26-Apr-19.
Strings in Java.
Visual Programming COMP-315
Topics Basic String Operations String Slicing
Switch, Strings, and ArrayLists in Java
In Java, strings are objects that belong to class java.lang.String .
Dr. Abraham Professor UTPA
Topics Basic String Operations String Slicing
Unit-2 Objects and Classes
Presentation transcript:

String Manipulation

Assigning String Literals string s1; s1=“abc”; OR string s1= “abc”;

Copying Strings string s1=“abc”; string s2 = s1; OR string s2= string.Copy(s1);

Concatenating Strings string s1=“abc”; string s2=“xyz” string s3 = s1 + s2; OR string s3= string.Concat(s1,s2);

Reading from Keyboard string s = Console.ReadLine();

The ToString() Method int no = 123; string nstr =no.ToString(); OR string nstr =Convert.ToString(no);

Verbatim Strings Start with Symbol @ OR string s1 = @ “C:\myfolder\string.cs”; OR string s1 = “C:\\myfolder\\string.cs”;

Regular vs Verbatim Strings Console.WriteLine("This string contains a newline\n and a tab\t and an escaped backslash\\"); Console.WriteLine(@"This string displays as is. No newlines\n, tabs\t or backslash-escapes\\.");

Types of C# String C# Strings Immutable Mutable System.String StringBuilder Regular Expressions

Immutable String Methods String Class Compare() CompareTo() Concat() Copy() CopyTo() Endswith() Equals()

Immutable String Methods IndexOf() Insert() Join() LastIndexOf() PadLeft() PadRight()

Immutable String Methods Remove() Replace() Split() StartsWith() Substring() ToLower() ToUpper()

Immutable String Methods Trim() TrimEnd() TrimStart()

Mutable Strings Methods StringBuider Class Append() AppendFormat() EnsureCapacity() Insert() Remove() Replace()

Regular Expressions Regular Expressions provides tool for searching and manipulating a large text . Namespace: System.Text.RegularExpressions

Regular Expressions Pattern String (Literals, Metachar) “\bm” Meaning “\bm” Any Word beginning with m “er\b” Any Word ending with m “\BX\B” Any X in the middle of a word “\bm\S*er\b” Any word beginning with m and ending with er. “|,” Any word separated by a space or a comma

Arrays of Strings String [ ] itemArray=new String[3]; Example: String [ ] itemArray={“Java”, “C++”, “Csharp” }; Properties and Methods: itemArray.Length; Array.Sort(itemArray); Array.Reverse(itemArray);