logo
Tags down

shadow

Remove a value from comma separated string in C#


By : Cathy Rosettsky
Date : October 14 2020, 02:21 PM
I wish this helpful for you If you want output as string you don't need to Split. Just get the LastIndexOf the , character and perform Substring on the variable:
code :
var a = "77,82,83";
var newString = a.Substring(0, a.LastIndexOf(',')); // 77,82
var a = "77,82,83";
var lastIndex = a.LastIndexOf(',');

if (lastIndex > 0)
    var newString = a.Substring(0, lastIndex);
a = string.Join(",", a.Split(',').Where(i => i != "83"));


Share : facebook icon twitter icon

Remove trailing comma from comma-separated string


By : user3659276
Date : March 29 2020, 07:55 AM
I hope this helps . To remove the ", " part which is immediately followed by end of string, you can do:
code :
str = str.replaceAll(", $", "");
String str = "kushalhs, mayurvm, narendrabz, ";
str = str.replaceAll(", $", "");
System.out.println(str);  // prints "kushalhs, mayurvm, narendrabz"

Remove comma inside quoted string in a comma separated list


By : irvingm
Date : March 29 2020, 07:55 AM
will help you I have a string , Try something like this (for PHP < 5.3):
code :
$dst = array();
$str = '1,2,3,4,5,"6,000",7,8,9';

$state = false;
$buffer = '';
for ($i = 0, $lim = strlen($str); $i < $lim; $i += 1) {
  $char = $str[$i];

  switch ($char) {
    case ',':
      if (!$state) {
        $dst[] = $buffer;
        $buffer = '';
      }
      break;

    case '"':
      $state = !$state;
      break;

    default:
      $buffer .= $char;
  }
}

$dst[] = $buffer;

print_r($dst);

Remove value from String which is comma separated


By : Lee F.
Date : March 29 2020, 07:55 AM
it helps some times if 12.1 that should be replaced as blank is the only word in that string you can use this:
code :
stringValue.replaceAll("^12\\.1$","blank");
stringValue.replaceAll("12\\.1,","");
stringValue= stringValue.replaceAll("^12\\.1$","blank").replaceAll("12\\.1,","");

How create array from comma separated string, sort it low to high, then join it back into comma separated string?


By : Daniel Schuster
Date : March 29 2020, 07:55 AM
With these it helps The first step is splitting the string in specified places, in your case - comma ,. Then use simple sort function and then you just have to join it, again with the comma sign.
code :
var orders = '1115672,1115676,1115677,1115682,1115684';

console.log(orders.split(',').sort((a,b) => a-b).join(','));

What is an elegant way to convert a python dictionary into a comma separated keys string and a comma separated values st


By : David Zack
Date : March 29 2020, 07:55 AM
Does that help Use str.join(iterable) (Hint: don't name your dict dict):
Related Posts Related Posts :
  • C# - OleDBDataAdapter.Fill(DataSet) throws "No value given for one or more required parameters. "
  • What happens if we don't use DTOs in our API?
  • How to display to the console list from another class?
  • EF Core Db First - filter out tables based on schema name
  • How to do JSON POST
  • How to safely change the unique key with Entitiy Framework - Database First
  • CS0103 Error in Visual Studio on simple project containing only a textbox and button
  • How to make custom user claims be available in API requests
  • SharpZipLib throw System.IO.FileNotFoundException on commit update
  • C# - check if substring is present in arraylist of strings
  • SSIS Script Task move all files not working
  • Unhandled exception occurs after handling exception
  • Reading selected checkboxes as int
  • Why projection is not including navigation nested properties in EF Core 2.0?
  • Structure to XML C# WinForms
  • Manipulate textbox on gridview C#
  • C# similar bitwise operations resulting in different answers
  • Linq to SQL Random Timeouts on Simple Small Queries
  • Return type as IEnumerable instead of just List?
  • How to get transient DbContext in ASP.NET MVC Core?
  • Grouping data in ViewModel ASP.NET MVC & C#
  • Using a parameter's property in an ArgumentException
  • EF Unable to determine the relationship represented by navigation property
  • Moq: running flows with FluentValidation
  • "Reset" switch statement after value is equal
  • What does the question mark followed by a period mean if it is next to a variable?
  • How to P/Invoke os_log?
  • Deep copy object properties (including those with private setter) to another object of the same type
  • How to generate new back colour if two object's back colour match?
  • How to calculate percentage of value inside arbitrary range?
  • typeof(T) when T is dynamically created is null?
  • Run the application faster with Run Query at Start
  • c# code returns System.Data.DataSet instead of Data itself?
  • Compile binaries to multiple versions of .NET Framework using Bazel
  • How to hide table rows in a DataList if column data returns null from SQL Server
  • Exception handling with lambda/linq statements
  • Creating a meal Cost calculator C#
  • Plugin Failing on D365 v9 Online when I just have tracers to test execution
  • ASP.NET MVC Deleting row from one table after copying it to another table
  • Error VSSDK1001: Unable to find Microsoft.VisualStudio.CommandTable.VSCTCompiler type
  • Trying to fetch a string from another form but i get string value null
  • Entity Framework equivalent of the following query?
  • How do I get projection of one list to another with Linq?
  • I am using Alpha Vantage API to try and pull daily stock info. I am really new to using APIs and don't know what I am do
  • Get column names and types out of XMLSchema
  • Unable to read large log file with MemoryMappedViewStream
  • looping through file to add to datagridview
  • C# How do I ask for Admin, without "forcing" him
  • System.ComponentModel.Win32Exception: "The system cannot find the file specified"
  • How to add list to SQL query?
  • Visitor pattern: Number arithmetics based on input
  • How to remove a single DataLabel from a Chart made with EPPlus and C#
  • GameObjects will not load after game Restarts
  • Getting all dates between two dates using datepickers and Entity Framework 6
  • What should TResult be when using public async Task to return json response from API HTTP Post
  • Automapper Sub Property Mapping
  • reading a json file exception "Unhandled Exception: System.TypeInitializationException: The type initializer for &q
  • How to get MacOS username in .NET Core console app?
  • How can I extract the first word of every line of a text file in C#
  • HttpClient isn't using Client Certificate for Mutual TLS Auth
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org