ഫലകം:Str mid

വിക്കിപീഡിയ, ഒരു സ്വതന്ത്ര വിജ്ഞാനകോശം.
ഫലകത്തിന്റെ വിവരണം[കാണുക] [തിരുത്തുക] [നാൾവഴി] [പുതുക്കുക]

Usage[തിരുത്തുക]

Characters in the source string are counted: the first is index 1, the last one is index length of string. The substring requested can be defined by these two indexes. Also, the substring can be defined by one index, and the substring length. The options are: {{str mid|<string>|<index of first character>|<length of substring>|<index of last character>}} It returns a part of the <string>, starting with character on position index, length <sublength>, last character returned is end index.

  • {{str mid|Abcdefghijklmnopqrstuvwxyz|5|3}} → efg

If parameter 2 is omitted, start is from character 1:

  • {{str mid|Abcdefghijklmnopqrstuvwxyz||5}} → Abcde

If parameter 3 is omitted, the whole rest of the string is returned:

  • {{str mid|Abcdefghijklmnopqrstuvwxyz|15}} → opqrstuvwxyz

Counting from the end[തിരുത്തുക]

By entering a negative value, the index is counted from the end:

  • {{str mid|Abcdefghijklmnopqrstuvwxyz|-7|4}} → tuvw
  • {{str mid|Abcdefghijklmnopqrstuvwxyz|-7}} → tuvwxyz

Instead if substring length, use index for last character[തിരുത്തുക]

By using parameter |4=n, a number, you do not ask for substring length, but the last character (as counted from the start of the input string):

  • {{str mid|Abcdefghijklmnopqrstuvwxyz|5||7}} → efg

Spaces are kept[തിരുത്തുക]

In the returned substring, spaces are kept:

  • >{{str mid|I like this.|2|6}}< → >like<

But the input string is trimmed:

  • >{{str mid| I like this. |2|6}}< → >like<

Error messages[തിരുത്തുക]

When the ranges (either param2 or the substring length) is out impossible in the string, an error is returned:

  • {{str mid|Abcdefghijklmnopqrstuvwxyz|30}} → String Module Error: String subset index out of range
  • {{str mid|Abcdefghijklmnopqrstuvwxyz|0|45}} → efghijklmnopqrstuvwxyz

The error can be suppressed by using |ignore errors=true. A blank (empty string) will be returned:

  • {{str mid|Abcdefghijklmnopqrstuvwxyz|0|45|ignore errors=true}} → efghijklmnopqrstuvwxyz

Error category[തിരുത്തുക]

  • |no category=true switches off category adding.
  • |error category=[[Category:Your category name]] sets the category to be added when in case of an error.
Default is Category:Errors reported by Module String.

See also[തിരുത്തുക]

"https://ml.wikipedia.org/w/index.php?title=ഫലകം:Str_mid&oldid=2278077" എന്ന താളിൽനിന്നു ശേഖരിച്ചത്
https://ml.wikipedia.org/wiki/%E0%B4%AB%E0%B4%B2%E0%B4%95%E0%B4%82:Str_mid
ml.wikipedia.org
crawl=CC-MAIN-2018-13
86435
application/http; msgtype=response
sha1:NWYXDG32WLYYMLLUJEBKLUURHO36H7RY
<urn:uuid:b5af9069-d841-40ce-be6d-068c82f21e92>
2018-03-22T21:35:48Z
208.80.154.224
text/html
sha1:3TB4BAQ3WNFSRKSFXQXB5IKOPPCOQY76
<urn:uuid:d0aa8580-b78d-41be-8727-e5425c2558b5>
https://ml.wikipedia.org/wiki/%E0%B4%AB%E0%B4%B2%E0%B4%95%E0%B4%82:Str_mid
length
response
<urn:uuid:460491b0-d231-4c16-b5b2-2c73eff9bb76>
robots: classic
hostname: ip-10-229-203-126.ec2.internal
software: Nutch 1.6 (CC)
isPartOf: CC-MAIN-2018-13
operator: Common Crawl Admin
description: Wide crawl of the web for March 2018
publisher: Common Crawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf