Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (798)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  String processor?  (Read 3166 times)
0 Members and 1 Guest are viewing this topic.
Offline jay4842
« Posted 2015-11-30 16:38:12 »

Does anyone have a tutorial on string processing? I'm currently working on an RPG and the string processor I have made doesn't always produce good results. For example it cuts out a letter or maybe a whole word. So any tutorial would help to be honest. Thanks!

edit:

Okay here is my main problem


it cuts off letters, for example it was supposed to say outer space, but it cut out the u. I realize now that I misspelled that but, thats my main issue. I take a string and split it into two strings. but when I do that it cuts out some things.

Also thank you for the feedback!
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #1 - Posted 2015-11-30 16:42:55 »

For example it cuts out a letter or maybe a whole word. So any tutorial would help to be honest. Thanks!

Use split to split by every space like this:
1  
2  
String myString = "Hello World";
String[] words = myString.split(' ');

returns
[0]Hello [1]World


Use split to split by every character like this:
1  
2  
String myString = "Hello World";
String[] characters = myString.split('.');

returns
[0]H[1]e[2]l[3]l ... 


Look up the docs for regex to find how to split more specific strings.
https://en.wikipedia.org/wiki/Regular_expression

Offline StrideColossus
« Reply #2 - Posted 2015-11-30 17:10:54 »

String processing is a quite wide field (try googling for it), suggest you provide a couple of examples of what you're hoping to achieve and someone should be able to offer some thoughts, tutorials, libraries, etc.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #3 - Posted 2015-11-30 19:45:00 »

String processing is a quite wide field (try googling for it), suggest you provide a couple of examples of what you're hoping to achieve and someone should be able to offer some thoughts, tutorials, libraries, etc.

String processing? The only way I can think of processing strings are regular expressions, it's not very wide. They're pretty easy to use too.

Googling string processing will get you the programming language "processing" on how to use strings... Regex is what OP is looking for.

Offline KevinWorkman

« JGO Plugged Duke »


Medals: 288
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #4 - Posted 2015-11-30 19:50:47 »

"String processing" is indeed very wide- are we talking about parsing xml? Taking commands from a user? Setting up properties? Natural language processing? Generating in-game dialogue? Something else?

Even "use regular expressions" is pretty wide.

We need to know more information from OP: what kinds of Strings are you trying to "process"? Exactly what do you want to happen? What have you tried so far?

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #5 - Posted 2015-12-01 01:14:04 »

I probably should have worded that better, and sounded less like an asshole xD. Sorry StrideColossus, have a medal

You're right, string processing is pretty wide in a way for the definition could be. I was looking at "ways for sorting characters in strings". But code relating strings in general... There's only so much Regex can do, and Java can substitute those pretty easily with a few shortcuts.

OP said earlier
For example it cuts out a letter or maybe a whole word.

He's mainly looking to sort strings... Regex is useful for that kind of stuff. He's just googling the wrong things.

Offline BurntPizza

« JGO Bitwise Duke »


Medals: 486
Exp: 7 years



« Reply #6 - Posted 2015-12-01 01:20:06 »

I, and I'll bet others, have no idea where you extrapolated that meaning from that quote. OP needs to define an actual problem.
Offline StrideColossus
« Reply #7 - Posted 2015-12-01 09:43:14 »

I probably should have worded that better, and sounded less like an asshole xD. Sorry StrideColossus, have a medal

No offence taken Smiley

And yes regex is possibly something the OP should be looking at.
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (28 views)
2019-09-04 15:33:17

hadezbladez (3957 views)
2018-11-16 13:46:03

hadezbladez (1434 views)
2018-11-16 13:41:33

hadezbladez (3954 views)
2018-11-16 13:35:35

hadezbladez (765 views)
2018-11-16 13:32:03

EgonOlsen (4079 views)
2018-06-10 19:43:48

EgonOlsen (4649 views)
2018-06-10 19:43:44

EgonOlsen (2748 views)
2018-06-10 19:43:20

DesertCoockie (3643 views)
2018-05-13 18:23:11

nelsongames (3834 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!