Questions tagged [string-length]

String length most commonly refers to the number of characters contained within a string. However, it could also mean the screen space a string takes up when printed.

This tag should be used for either of the two following types of questions:

  1. Those dealing with the number of characters contained within a string.
  2. Those dealing with measuring the size of a string (in pixels, millimeters, etc.) when it is printed on a screen.
1040 questions
-2
votes
3 answers

Adding length to my for loop program

I have created a program on pycharm which allows the user to input a number so a list of items can be created. The program is as follows: item = int(input("How many items do you want in your list? ")) stringList = [] for i in range(1, item +1): …
-2
votes
1 answer

JavaScript String Match and Length

So, I need you match all the characters from A-z in my code and then get the length of it. Basically I need to use a match in the string value, and then get the length of that match. Right now it doesn't work at all. If I remove the length, I get a…
UnderMyWheel
  • 241
  • 2
  • 11
-2
votes
1 answer

How to create a mySQL table with specified field length?

It should be fairly easy but I don't seem to find the answer anywhere else. If for example I have the following table how do I set the LastName field to be of an exact size? (not maximum) CREATE TABLE Persons ( PersonID int, LastName…
Rakim
  • 1,087
  • 9
  • 21
  • 40
-2
votes
1 answer

php match number for first 2 digits and length

I would need to check in php if the number has 10 digit length and the first 2 digits need to be 09 and check for no space too please? sample true number = 0912345678 Thanks Ramin
Ramin Rabii
  • 359
  • 4
  • 14
-2
votes
3 answers

How to shorten string to specific length according to textBox1.Length c#

I need to know how to shorten a string to a certain length, I tried string.Trim() but it is not working. Sorry I'm still a beginner. Thanks Edit I'm trying to cut off padding from decrypted text. For example: A user inputs text, the user encrypts…
Dilan V
  • 313
  • 1
  • 3
  • 13
-2
votes
1 answer

How to implement string length method in Java

I'm new here and very new to programming. I am actually taking a Intro to Programming in Java course right now and my teacher isn't super helpful so I would just like to have other people help me out with this. Anything will be appreciated. My…
MKBurns
  • 11
  • 1
-2
votes
1 answer

comparing 2 char* with different lengths without null terminators

I am trying to compare the string literal values of two char* of different lengths. They don't have null terminators so I can't use strcmp. How should I determine if they are equal? Is there a method that I could use? Example code: int main(){ …
-2
votes
1 answer

How to extract an undefined length of a string in Postgres

I am really new at sql and I want to extract 'SWAMP RIVER NEAR DOVER PLAINS NY' from the following string: 01199490 SWAMP RIVER NEAR DOVER PLAINS NY The problem is that…
Alan Alves
  • 61
  • 1
  • 2
  • 9
-2
votes
3 answers

Is len(text.split()) faster than text.count(" ")? And why so? python

Given that I have 1,000,000,000 lines of ~20-100 tokens per line delimited by whitespace, counting the length of each line becomes sort of non-trival. Assuming that there are never double whitespaces between two tokens, Is len(text.split()) faster…
alvas
  • 115,346
  • 109
  • 446
  • 738
-2
votes
2 answers

Printing the length of a string from a label

I am currently trying to check the length of a label. What it is is i want the label to display "Unavailable" if the string is of a null value. The sting is being read in from a XML sheet so i don't know what the length of the actual string is and…
-3
votes
5 answers

Python Beginner lerning len

I am doing some exercises, and I am a beginner in python. Doing some coding challenge and there was an exercise that tells me I should ask my name, and it should show me how many letters my name has. My first solution was: name = "What is your…
Aura
  • 1
-3
votes
3 answers

Why the strlen() function doesn't return the correct length for a hex string?

I have a hex string for example \xF5\x17\x30\x91\x00\xA1\xC9\x00\xDF\xFF, when trying to use strlen() function to get the length of that hex string it returns 4! const char string_[] = { "\xF5\x17\x30\x91\x00\xA1\xC9\x00\xDF\xFF" }; unsigned int…
Lion King
  • 32,851
  • 25
  • 81
  • 143
-3
votes
1 answer

Construction of a string

You are given three positive integers n, a and b. You have to construct a string s of length n consisting of lowercase Latin letters such that each substring of length a has exactly b distinct letters. Please provide hints on how to solve. Please…
AKASH ROY
  • 13
  • 5
-3
votes
3 answers

How Do I Solve This JavaScript String length Property Error?

I am learning to code and I've been working on this one item for over an hour. The code for the string length property is not correct. // I have tried: length.length; num.toString(); //"6" length.length; //6 //////The exercise is below function…
Sabrina73
  • 1
  • 1
-3
votes
2 answers

Stuck. New to JS. Trying to figure this out since hours

I can't solve exercise three and four. I would be very pleased to get some help. Thank you in advance! function exerciseThree(str){ // In this exercise, you will be given a variable, it will be called: str // On the next line create a variable…