Saturday, November 26, 2016

String.Split Method (Char[])

              We use String.Split(Char[]) to split a string into sub-strings that delimited by  a specified character in an array. Each sub-string does not contain delimiter. This method take argument as an array of characters and return sub-string that we mentioned.

Example

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace String_Split_Char
{
    class Program
    {
        static void Main(string[] args)
        {
            String nayDemo = "My name is Nay Man,I am a student. I Study at Royal University of Phnom Penh";
            char[] nayDelimiter = {' ','\0',',','.' };
            //String[] sub_nayDemo = nayDemo.Split(nayDelimiter,StringSplitOptions.RemoveEmptyEntries);
            String[] sub_nayDemo = nayDemo.Split(nayDelimiter, StringSplitOptions.None);
            foreach (String tmp in sub_nayDemo)
            {
                Console.WriteLine(tmp);

            }
        }
    }
}



String In R Programming

             All literal string  in R programming was write in single or double quotes. You can not use mixed string quote and double quotes. for example( "Mr. Nay'), you must write like this ('Mr. Nay' or "Mr. Nay").

Please See in Console
1.


Result is correct

2.


Result is correct
3.

Result is not correct.

String Manipulation

          1.Check Information of  any variable

                1.1/function is.character(str)
                         use for check value of variable whether string or others. Why we need to check value               of  variable .Every programmer that learned R-programming, know that we use variable in R    
            by assign value not define type like other programming (c ,C++, C#, Java...). To understand                   well please see examples below:


                 


              1.2/function as.character(str)
                          use for convert value of variable that is not string to string. Above example variable   "st2" store value that have type as Number not character so if you want to convert it strin                     you use function as.character(str). please sea example below:


          1.3/function nchar(str)
                 used for count number of string variable. please see example below

         

Friday, November 25, 2016

How To Use Explode In Php

              We use explode function to split a string into an array of strings by using string delimiter.
String delimiter is the string that use for separate a string  into sub-string at any string in source string that equal to delimiter.
for example

<html>
<head>
<title>My php</title>
</head>
<body>
<?php
$str="Mr ISteav How We ARe";
$str1=explode("H",$str);
foreach ($str1 as $value){
echo '<p>'.$value.'</p>';
}

?>
</body>
</html>


example above function explode will spilt $str into two string at "H" in $str



how to use trim method in php

                  We use trim($str) function in php to remove all white-spaces from starting and ending of string-data . Characters that we refer to white-space such as (space, tab, new line, carriage return, null-character, vertical-tab). 
                For example,
<html>
       <head>
                <title > Learn Php</title>
      </head>
      <body>

          <?php
                  $str=" I am a Student ";
                  echo '<p>'.'"We have String $str=" I am a Student "'.'</p>';
                 echo '<p>'."Before Trim:".$str,"Mr. Steav";
                echo '<p>'."After Trim:".trim($str),"Mr.Steav";

             ?>
         </body>
</html>

          Moreover, we can remove any characters from starting and ending from string-data by using function trim($str,$anycharacters). For Example, When you want to get any string value without any character at starting and ending of it.

please below:

<html>
          <head>
               <title > Learn Php</title>
          </head>
          <body>

          <?php 
                     $str="I am a m I Student m";
                    echo '<p>'.'When You Want to remove "I am" from "$str"'.'</p>';
                    echo '<p>'.'Before trim:'.$str."at RUPP".'</p>';
                    echo '<p>'.'After trim:'.trim($str,"I am")."at RUPP".'</p>';

            ?>
         </body>
</html>

            In example above  function trim will remove any character such as (I,space,a,m) from starting and ending of $str.

Please see result: