How to check if a character is a not a part of number or URL in string?

How to check if a character is a not a part of number or URL in string?

Content Index :

How to check if a character is a not a part of number or URL in string?
Tag : python , By : Vodkat
Date : January 11 2021, 03:32 PM

this one helps. You should only really have to check to see if the character after the delimiter is a white space to tell if it's not at the end of the sentence. No re needed.
delimiters = ['!', '?', '.']
def is_delimiter(char, next_char):
    if char in delimiters:
        if next_char is not None:
            if next_char == ' ':
                return True
            return True
    return False

text = "Hello. I'll come back on 12.09."

for i in range(0, len(text)):
    char = text[i]

    j = i+1

    if j < len(text):
        next_char = text[j]
        next_char = None

    print(char, is_delimiter(char, next_char))

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to separate character and number part from string

Tag : chash , By : nonkelhans
Date : March 29 2020, 07:55 AM
this will help E.g., I would like to separate: , I have used bniwredyc's answer to get Improved version of my routine:
    private void demo()
            string cell = "ABCD4321";
            int row, a = getIndexofNumber(cell);
            string Numberpart = cell.Substring(a, cell.Length - a);
            row = Convert.ToInt32(Numberpart);
            string Stringpart = cell.Substring(0, a);

        private int getIndexofNumber(string cell)
            int indexofNum=-1;
            foreach (char c in cell)
                if (Char.IsDigit(c))
                    return indexofNum;
            return indexofNum;

select part of a string after certain number of special character

Tag : r , By : liquidx
Date : March 29 2020, 07:55 AM
I hope this helps you . I have a data.table with a column , If k is the number of fields to keep:
k <- 2
DT[, V1 := do.call(paste, c(read.table(text=V1, fill=TRUE, sep="_")[1:k], sep = "_"))]

DF <- data.frame(V1 = c("a_b_c_las_poi", "a_b_c_kiosk_pran", "a_b_c_qwer_ok"),
   stringsAsFactors = FALSE)
DT <- as.data.table(DF)

String having a text part and number part separated through match function does not increment number part by 1 after 8

Tag : javascript , By : lifchicker
Date : March 29 2020, 07:55 AM
wish of those help The OP reports that parseInt('00008'); returns 0 (zero) instead of decimal 8 (eight). The reason is that the leading zeros are causing parseInt to assume base 8 (instead of base 10).

Check if part of a string is a number

Tag : php , By : Revision17
Date : March 29 2020, 07:55 AM
this one helps. I don't know exactly what kind of data you will receive, but it looks like you can use a regular expression. For example, assume that $uri is the string and you want a number in the format: "/room/NUMBER/messages". You can use:
preg_match("~/room/([0-9]+)/messages~", $uri, $matches);
if(isset($matches[1])) {
  $roomnumber = $matches[1];
  // do what you want
} else {
  // There is no room number

Check if any part of a string input is not a number

Tag : java , By : foxthrot
Date : March 29 2020, 07:55 AM
it should still fix some issue I would personally create my own helper methods for this, instead of using an external library such as Apache (unless you already plan on using the library elsewhere in the project).
Here is an example of what it could look like:
public static void main(String[] arguments) {
    String time = "10:50:45";
    String [] arr = time.split(":");

    if (containsNumbers(arr)) {
        System.out.println("Time contained a number!");
    //You can put an else if you want something to happen when it is not a number

private static boolean containsNumbers(String[] arr) {
    for (String s : arr) {
        if (!isNumeric(s)) {
            return false;
    return true;

public static boolean isNumeric(String str) {
    return str.matches("-?\\d+(.\\d+)?");
String time = "sd:fe:gbdf";
returns false

String time = "as:12:sda";
returns false

String time = "10:50:45";
returns true
Related Posts Related QUESTIONS :
  • Is there a more efficent way to extend a string?
  • How to calculate each single element of a numpy array based on conditions
  • How do I change the width of Jupyter notebook's cell's left part?
  • Measure distance between lat/lon coordinates and utm coordinates
  • Installing megam for NLTK on Windows
  • filter dataframe on each value of a samn column have a specific value of another column in Panda\Python
  • Threading with pubsub throwing AssertionError: 'callableObj is not callable' in wxPython
  • Get grouped data from 2 dataframes with condition
  • How can I import all of sklearns regressors
  • How to take all elements except the first k
  • Whats wrong with my iteration list of lists from csv
  • Tensorflow Estimator API save image summary in eval mode
  • How to Pack with PyQt - how to make QFrame/Layout adapt to content
  • How do I get certain Time Range in Python
  • python doubly linked list - insertAfter node
  • Open .h5 file in Python
  • Joining a directory name with a binary file name
  • python, sort list with two arguments in compare function
  • Is it possible to print from Python using non-ANSI colors?
  • Pandas concat historical data using date minus some number of days
  • CV2: Import Error in Python OpenCV
  • Is it possible to do this loop in a one-liner?
  • invalid literal for int() with base 10: - django
  • Why does my code print a value that I have not assigned as yet?
  • the collatz func in automate boring stuff with python
  • How to find all possible combinations of parameters and funtions
  • about backpropagation deep neural network in tensorflow
  • Sort strings in pandas
  • How do access my flask app hosted in docker?
  • Replace the sentence include some text with Python regex
  • Counting the most common element in a 2D List in Python
  • logout a user from the system using a function in python
  • mp4 metadata not found but exists
  • Django: QuerySet with ExpressionWrapper
  • Pandas string search in list of dicts
  • Decryption from RSA encrypted string from sqlite is not the same
  • need of maximum value in int
  • a list of several tuples, how to extract the same of the first two elements in the small tuple in the large tuple
  • Display image of 2D Sinewaves in 3D
  • how to prevent a for loop from overwriting a dictionary?
  • How To Fix: RuntimeError: size mismatch in pyTorch
  • Concatenating two Pandas DataFrames while maintaining index order
  • Why does this not run into an infinite loop?
  • Python Multithreading no current event loop
  • Element Tree - Seaching for specific element value without looping
  • Ignore Nulls in pandas map dictionary
  • How do I get scrap data from web pages using beautifulsoup in python
  • Variable used, golobal or local?
  • I have a regex statement to pull all numbers out of a text file, but it only finds 77 out of the 81 numbers in the file
  • How do I create a dataframe of jobs and companies that includes hyperlinks?
  • Detect if user has clicked the 'maximized' button
  • Does flask_login automatically set the "next" argument?
  • Indents in python 3
  • How to create a pool of threads
  • Pandas giving IndexError on one dataframe but not on another similar dataframe
  • Django Rest Framework - Testing client.login doesn't login user, ret anonymous user
  • Running dag without dag file in airflow
  • Filling across a specified dimension of a numpy array
  • Python populating dataframe in pandas from text files
  • How to interpolate a single ("non-piecewise") cubic spline from a set of data points?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com