Home » Search results for 'javascript string'

Linked Lists in Python – How to Use Them, With Examples

Python Linked Lists

This article will explain in simple terms what linked lists are, why they’re useful, and how to use them in the Python programming language. Lists In Python, a list is an array of data – a simple list of values where each item has a value and a position in the list. Lists are indexed (so the positions start counting at position 0, not 1). For more information on lists in Python, check out these LinuxScrew articles: Python List ‘sort()’ Method – Sorting Lists in Python Easily … Read more

Home » Search results for 'javascript string'

Using the ‘sed’ Command in Bash/Linux, With Examples

The sed (Stream EDitor) command in Bash/Linux reads text from a stream or file and performs line-by-line operations on it based on a set of supplied criteria.  Here’s how to use it. sed is an automated way to process text. One simple example of where sed can be used is doing a simple find-and-replace for a word in a text document – the text with the words replaced can then be saved to a new file or overwrite the original. Why? Being able to modify text – either from a … Read more

Home » Search results for 'javascript string'

isdigit(), isalpha() and Other Checks in Python, With Examples

Both Python versions 2 and 3 provide several helpful string methods that let you find the string’s contents.  Here’s how to use them. The functions in this article are useful if you want to validate user input – for example, you may want to check that a user-inputted string is a valid number before converting it to a number variable to prevent errors and warn the user that they need to try again. isdigit() and isalpha() are commonly used methods to identify a string’s contents, but … Read more

Home » Search results for 'javascript string'

How to Get User Input in Python [With Examples]

This article covers getting user input on the command line using Python 2 or 3 and includes some useful examples. Get User Input in Python 3 Python 3 uses the input() function to collect user input: myText = input(“Enter some text:”) print(“You entered the text: ” + myText) Get User Input in Python 2 If you’re still using Python 2, you will use the raw_input() function instead: myText = raw_input(“Enter some text:”) print “You entered the text: “, myText # Python 2 uses different syntax to print output Typing Input … Read more

Home » Search results for 'javascript string'

PHP var_dump() Function [With Examples]

The PHP programming language includes various built-in variable types and allows you to create your own complex object classes. Third-party packages also come with their own object classes. So it’s useful to find out what type of variable a variable is, its value, and the type/value of any properties or values the variable may contain. The PHP var_dump() function returns a given variable or value’s properties, including the value and type. It works through the variable’s properties or value recursively doing the same. Read on to learn … Read more

Categories PHP

Home » Search results for 'javascript string'

touch Command in Linux and Bash [with Examples]

The touch command in Linux updates the timestamps on a file or creates the file if it doesn’t exist. See some examples and use cases below. It sounds useless, but it’s actually useful. For example, if you want to create an empty file called my_file.txt, you can just run: touch my_file.txt Easy! Updating the timestamps of a file is also useful. Say you have a file called favorite_tv.txt, which you use to keep the name of your current favorite TV show. Your favorite show 10 years ago was … Read more

Home » Search results for 'javascript string'

PHP strtotime() Function – Converting Text to Timestamp [With Examples]

The PHP strtotime() function takes a string containing text and converts it to a Unix Timestamp. Find out how to use this function in this guide. A Unix timestamp is a number representing the number of seconds since 00:00:00 UTC on 1 January 1970. From it, you can build more complex Date/Time objects which can readily provide Dates/Minutes/Hours/Seconds or other information about the supplied time. strtotime Syntax strtotime ($datetime , $baseTimestamp) Note that: $datetime is your supplied text string (possibly) containing a date strtotime() supports the English language only See … Read more

Categories PHP

Home » Search results for 'javascript string'

Bash For Loop [With Examples]

The for loop is a handy tool when writing Bash scripts for repeating a task for a number of files, records, or other values. The for statement will iterate over a list of values, performing tasks on each one until all items have been processed. Usage cases include looping over the files in a directory, the lines in a text file, or the output of a database query. Bash For Loop Syntax for VARIABLE in LIST do COMMANDS done Where: VARIABLE is the variable name that will … Read more

Home » Search results for 'javascript string'

Linux wget Command Guide [With Examples]

If you followed our Magic Mirror tutorial, you’d see the wget command was used to download some files. This tutorial explains how to use wget, a command-line tool for downloading (getting) files from the web, be it via HTTP, HTTPS, FTP, or FTPS. Use it to download files from the internet from the Linux shell, call it from Bash scripts – it’s simple and versatile and doesn’t require user interference once started so that it can run in the background. Syntax wget [OPTIONS]… [ URLS ]… … Read more

Home » Search results for 'javascript string'

PHP trim() Function [With Examples]

You’ll want to process and tidy your user input before you do anything with it when building PHP apps. trim() is one of the tools available to do this – it removes all white space from the beginning and end of a string. Whitespace is things like spaces, tabs, and newlines which may be invisible to the user. PHP trim Syntax trim ( $string [, $character_mask = ” \t\n\r\0\x0B” ] ) Note that: By default, $string will be returned by trim() with all whitespace removed from the beginning and end, including: … Read more

Categories PHP
Exit mobile version